Search code examples
ubunturuby-on-rails-4unicorn

How to keep unicorn running in Ubuntu?


I have a Digital Ocean droplet running with Ubuntu, Rails, Nginx and Unicorn. I'm doing deployments with Mina. When I do a deployment I can execute

bundle exec unicorn

And I can visit the web url and see the site running, however as soon as I logout from my remote ssh session, the Unicorn processes die (I'm assuming this) and the site is no longer available.

What's the way to keep unicorn running after I logged out from the console? Thanks


Solution

  • Running the unicorn command without the -D option (daemonize) runs the unicorn process in the current shell, which is running via the mina deploy process. So as soon as the mina command finishes, the remote shell is ended and the unicorn command stopped. You either need to use the -D option or use a OS level process manager(i.e. Upstart for Ubuntu).