Playing around with rails and gem

#建站合集SysAdmin

I tried to set up a sort of soundcloud service today, built using Ruby on Rails for backend with PostgreSQL for the database and ReactJS for the front end.

While I was connected to the vps, “rails server”-ed the server, I had to left my desk for a few minutes, and by the time I was back, the ssh connection was already “reset by peer”.

Then when I was back connected again and tried to relauch the rails server, it gave a warning of “Server is already running in Rails”.

Here is the solution that worked for me:

The following is a copy of the content linked above..

Root Cause:

Because PID is locked in a file and web server thinks that if that file exists then it means it is already running. Normally when a web server is closed that file is deleted, but in some cases, proper deletion doesn't happen so you have to remove the file manually New Solutions

when you run rails server:

A server is already running. Check

/your_project_path/tmp/pids/server.pid.

Exiting

So place your path shown here...

/your_project_path/tmp/pids/server.pid

...and remove this server.pid file:

rm /your_project_path/tmp/pids/server.pid

OR Incase you're server was detached then follow below guidelines:

If you detached you rails server by using command “rails -d” then remove rails detached server by using command

ps -aef | grep rails

OR by this command

sudo lsof -wni tcp:8080

then

kill -9 pID

OR use this command

To find and kill process by port name on which that program is running. For 8080 replace port on which your program is running.

sudo kill -9 $(lsof -i :8080 -t)