Can't Start Rails Development,Cloud 9 - ruby-on-rails

I've tried to kill my rails server using this article from cloud 9.
I'm using the gem thin and everytime I try to run cloud server command I recieve this error
rails s -b $IP -p $PORT
=> Booting Thin
=> Rails 4.2.6 application starting in development on http://0.0.0.0:8080
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Thin web server (v1.6.4 codename Gob Bluth)
Maximum connections set to 1024
Listening on 0.0.0.0:8080, CTRL+C to stop
Exiting
/usr/local/rvm/gems/ruby-2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:530:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)
from /usr/local/rvm/gems/ruby-2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:530:in `start_server'
from /usr/local/rvm/gems/ruby-2.3.0/gems/thin-1.6.4/lib/thin/backends/tcp_server.rb:16:in `connect'
from /usr/local/rvm/gems/ruby-2.3.0/gems/thin-
full error

It seems the port 8080 is in use, to find the PID using the port, run :
netstat -tulpn | grep :8080
Then you can kill -9 <PID>

This error says, 8080 port already in use, you may need to use different port for you application
Update:
Try to kill the existing process. Find port number using this command ps -ef | grep thin and then kill it kill -9 <port>. Try running your app now.

Related

Multiple concurrent rails servers with binding

I have a rails staging server available to my LAN as follows:
rails server --binding=0.0.0.0 -p 3000
I would now like to open up a second, concurrent rails server to my LAN as follows:
rails server --binding=0.0.0.0 -p 3001
Unfortunatly, I am getting this error message:
...
=> Booting Puma
=> Rails 5.1.1 application starting in development on http://0.0.0.0:3001
=> Run `rails server -h` for more startup options
A server is already running. ...
The error only exists if I use --binding=0.0.0.0 on both servers, which is necessary if I want it to be accessible to my LAN.
How can I open up multiple rails servers on the same machine to the LAN, not just localhost?
EDIT:
After trying Vasfed's solution, e.g.
rails server --binding=0.0.0.0 -p 3000 --pid=tmp/pids/server0.pid
rails server --binding=0.0.0.0 -p 3001 --pid=tmp/pids/server1.pid
the problem persists, but this time I have more information. It seems related to a port 9292 being opened...
=> Booting Puma
=> Rails 5.1.1 application starting in development on http://0.0.0.0:3001
=> Run `rails server -h` for more startup options
*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Version 3.9.1 (ruby 2.4.1-p111), codename: Private Caller
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://0.0.0.0:9292
Exiting
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/puma-3.9.1/lib/puma/binder.rb:269:in `initialize': Only one usage of each socket address (protocol/network address/port) is normally permitted. - bind(2) for "0.0.0.0" port 9292 (Errno::EADDRINUSE)
Rails checks if a pid file is already present. To run two copies of single app, you should alter pids too:
rails server --binding=0.0.0.0 -p 3000 --pid=tmp/pids/server1.pid
rails server --binding=0.0.0.0 -p 3001 --pid=tmp/pids/server2.pid

When starting rails server "Uncaught exception: no acceptor (port is in use or requires root privileges)"

I Updated the output to make it more readable. Still getting this error.
Noob question. Has anyone else seen this error? This error seems to be spreading. It now happens for port 3000 and 3001. If I change the code and debug settings to 3002 then I can continue debugging.
--------------------------------------------------------------
-------------------------------------------------------------
$: rails s -p 3000
=> Booting Thin
=> Rails 3.2.11 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Thin web server (v1.6.4 codename Gob Bluth)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop
Exiting
/home/xxx/.rvm/gems/ruby-1.9.3-p551#ats/gems/eventmachine-1.0.8/lib/eventmachine.rb:534:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)
run
ps ax | grep rails
this will return the process number of the rails server currently running
then you can do
kill -9 *process_numer*
this answer assumes that you accidentally quit rails server by pressing Ctrl+Z instead of Ctrl+C which did no dispose of the process properly and is now tying up the port.
This error occurs when some process is already using that port.
Usually this happens when rails server is already started (for example - for other project, and you forgot to stop it)
Use ps ax | grep rails | grep -v grep and lsof -n -i4TCP:3000 | grep LISTEN to find rails servers and processes using port 3000

Rails app can't connect to private_pub on Vagrant

I have a rails app that uses private_pub. Somehow I can't get my app to connect to private_pub.
Is there a way to bind private_pub to 0.0.0.0?
Run rails server
vagrant#vagrant:/vagrant$ rails s -b 0.0.0.0
=> Booting Thin
=> Rails 4.2.2 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Thin web server (v1.6.2 codename Doc Brown)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop
Start private_pub
vagrant#vagrant:/vagrant$ rackup private_pub.ru -s thin -E production
Thin web server (v1.6.2 codename Doc Brown)
Maximum connections set to 1024
Listening on localhost:9292, CTRL+C to stop
Chrome console log
http://localhost:9292/faye/faye.js net::ERR_EMPTY_RESPONSE
Yes, there is a way, it's documented feature. From docs:
server: The URL to use for the Faye server such as http://localhost:9292/faye.
so you can configure your config/private_pub.yml for the environment you need like this:
development:
server: "http://0.0.0.0:9292/faye"
secret_token: "secret"
Then start a server with:
thin -C config/private_pub.yml -p 9292 start
Using rack adapter
Thin web server (v1.6.4 codename Gob Bluth)
Maximum connections set to 1024
Listening on 0.0.0.0:9292, CTRL+C to stop
I actually don't know why it doesn't catch the port number(I opened the issue in github), so I specified it explicitly.
Second option is to set a host for rackup command(since in this way it doesn't properly handle the address):
rackup private_pub.ru -s thin -E production -o 0.0.0.0
Thin web server (v1.6.4 codename Gob Bluth)
Maximum connections set to 1024
Listening on 0.0.0.0:9292, CTRL+C to sto
You can also specify explicitly both the address and the port for thin(as well as for rackup) and omit config file at all(probably not a good idea since there are secret_token and signature_expiration options in config file which should be set):
thin -a 0.0.0.0 -p 9292 start
Using rack adapter
Thin web server (v1.6.4 codename Gob Bluth)
Maximum connections set to 1024
Listening on 0.0.0.0:9292, CTRL+C to stop

Production mode is not running on port 80 (Rails)

I don't understand why it's not running on port 80 instead of port 3000 when I run the command RAILS_ENV=production rails s on the same line. I want it to run in production mode but it's not running on the correct port. Anyone know why? I'm trying to use Rubber but I haven't ran any commands for it only just changed some of the files like it says in this tutorial.
root#ip-000-00-00-000:/home/ubuntu/Git/# RAILS_ENV=production rails s
=> Booting Thin
=> Rails 3.2.11 application starting in production on \http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
\>> Thin web server (v1.5.1 codename Straight Razor)
\>> Maximum connections set to 1024
\>> Listening on 0.0.0.0:3000, CTRL+C to stop
^C>> Stopping ...
Exiting
webrick runs on port 3000 by default(even in production mode). Pass the port number explicitly if you want to run on a different port.

How to show application requests on terminal window while using Thin and Rails 3.0

I started using Thin instead of WEBrick in development (Rails version 3.0.9)
With WEBbrick, I would see all the requests listed (and calls to the database) in the terminal window while the server was running.
How do I get that with thin? When I do thin start the only output I see is:
>> Using rack adapter
>> Thin web server (v1.2.11 codename Bat-Shit Crazy)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop
Try thin start -V.
https://github.com/macournoyer/thin/blob/master/lib/thin/runner.rb#L134
opts.on_tail("-V", "--trace", "Set tracing on (log raw request/response)")
try rails server thin -b 0.0.0.0 -p 3000 -e development
or run it with bundle
bundle exec rails server thin -b 0.0.0.0 -p 3000 -e development

Resources