Search code examples
ruby-on-railsrubyubunturuby-on-rails-5ubuntu-14.04

Ubuntu run Puma and Sidekiq in background as Daemonized processes


Two years ago I was running the following command:

bundle exec puma -C config/puma.rb -b unix:/home/user/site/shared/tmp/sockets/user-puma.sock -d
bundle exec sidekiq -d

But now, after some Ubuntu updates, the -d flag is deprecated and I can't start the Puma and Sidekiq processes to run in background.

I also tried running:

bundle exec puma -C config/puma.rb -b unix:/home/user/site/shared/tmp/sockets/user-puma.sock &
bundle exec sidekiq &

This works only while I'm logged on the SSH, when I close the SSH connection, all processes opened with & are closed.

How can I run Puma, Sidekiq and other processes in background as Daemons?


Solution

  • What works for me is setting up my own systemd service for sidekiq

    A well-documented example file is in the sidekiq github repository

    Along with this, I'd also recommend using monit to watch background processes... here's a recipe from Lugo Labs that I loosely base my deploys off of