0

I have the code and db set up on the server. I run the command rails s, but the server shutsdown once my local system shuts down. Is there a way to keep the webserver running on the server. Capistrano might not be necessary as i have the code on the server itself. Webrick is the webser am currently using.

This is first deployment and any help will be much appreciated.

Thanks in advance.

LS2
  • 152
  • 3
  • 16

3 Answers3

1

It is very uncommon to use WEBrick in Production. There's a Stack Overflow discussion of why and a lot of people telling you not too all over the web. I'm really not a fan of "Because everybody says so!" answers, but a Google will find you lots and lots of opinions.

However, if your application isn't very widely used and you've resources to spare on your server, you can run in daemon mode when you start your server:

rails server -d

however, the only way to stop this once started is to get the pid and call kill on the process:

kill -9 thepidhere (I found -9 to be necessary or it refused to stop)

If you want to change to another server, check out thin, Unicorn and Nginx. For a big, beefy, customizable solution, check out this post about Apache and Mongrel.

Community
  • 1
  • 1
Dylan Lacey
  • 1,839
  • 12
  • 23
0

Try running your application on thin server.

write gem 'thin' in your gemfile.
do bundle install
write thin start rather rails s.
Your server won't get stopped untill and unless you write thin stop

I think the above will work for you.

VenkatK
  • 1,295
  • 1
  • 9
  • 21
0

You have to make a daemon process so it can run even without your local terminal open with the command rails s. Try something like rails s -d . You can also install passenger and write passenger start -d or thin and write rails s -d.

For a better deployment it would be a good idea to add an initialize script to automatically starts your application if you are running it with a standalone way like the above.

JohnDel
  • 2,092
  • 8
  • 35
  • 64