How to make sure that rails server is running in background on a vps

209 views Asked by At

I have recently deployed an application linode vps. I tried getting support from them but no luck. I installed nginx and passenger etc but unable to get it to work.

So I just started the rails server on 8080 port and it was accessible via the ip address directly.

My problem is that everytime I close my laptop or disconnect from internet, the web brick server stops running. I have also tried starting it in background with adding &, but no help.

When I go into screen, rvm or rails, both are unavailable.

Please suggest how can I ensure that it works continuously. The vps is running ubuntu 14.04 lts. Rails 4, ruby 2.1.1

I always have tough time with this part.. if there is a script / tool / or gem available to simplify this part, that would be great.

2

There are 2 answers

0
Rubyrider On BEST ANSWER

Try using GOD or Monit like services, that can both help finding when servers(can be many, like caching servers, mongodb servers, database servers, http servers, app servers like passenger/unicorn/puma, full text search engines servers (elastic search/solr/thinking-sphinx) etc..) goes down and take steps as you define when exception occurs. Beside, consider using third party services like new relic. You can set alert messages on events and set timing for any alert or current state reports like thingy as well. I hope I could help you understanding the idea by answer. Thanks

0
Stanislav Mekhonoshin On

Check out this tutorial. http://gistflow.com/posts/544-runit-the-missing-how-to

In a couple words - you should use supervisor, that starts your ruby server. It will restart app, when it crashed. It will start app after VPS reboot. And so on.