In Ubuntu, I can run a rails server in the background as a daemon by passing in the --daemon option;
bundle exec puma -e production -b unix:///var/run/my_app.sock --daemon
However, how do I gracefully shut this daemonized process down? It's not a simple matter of crtl + c anymore :)
It is better to use puma control pumactl, it processes monitor and controller.
and then you can use it like this to stop
bundle exec pumactl -P /var/run/puma.pid stop
OR
pumactl -C unix://var/run/my_app_pumactl.sock [status|restart|halt|stop]
Related
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?
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
We are currently using capistrano-sidekiq, this also handles the automatic restart of sidekiq on each deploy.
However, we also want to manually restart sidekiq each night, without rebooting the whole application.
Which command should be used to automatically restart sidekiq on the production machine using a crontab entry on this machine ?
Find existing sidekiq process and kill it and then start sidekiq again
To run Sidekiq
RAILS_ENV=production bundle exec sidekiq -d -L log/sidekiq.log -C config/sidekiq.yml
To Kill sidekiq process
RAILS_ENV=production bundle exec sidekiqctl stop tmp/pids/sidekiq.pid
I wonder what's the better practice to run rails server with Puma and nginx on reboot.
because my crontab doesn't work.
I want to learn how to run the server automatically in other ways
PATH=/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/home/userA/bin:/home/userA/.rbenv/shims:/home/userA/.rbenv/bin:/home/userA/.rbenv$
SHELL=/usr/bin/zsh
#reboot zsh -l -c 'cd /project && bundle exec puma config/puma.rb'
I'm using Foreman to run my Rails 4 application, and I'm getting duplicate output. Web shows pretty much the same info as Log.
Can I run foreman and just hide the Web output?
My procfile:
web: bundle exec passenger start -p $PORT --max-pool-size 3
log: tail -f ./log/development.log
The entries in your Procfile are just commands to run and you can tinker with them the same way you would on the command line.
So you could redirect all of the stdout for your web process to /dev/null (looks like you might be on a *nix system):
web: bundle exec passenger start -p $PORT --max-pool-size 3 > /dev/null
I have multiple workers, each of them seperated based on WorkerClass
Specified queues, concurrency etc. They are triggerin via cron jobs.
nohup bundle exec sidekiq -q worker1 -c 5 -e production
nohup bundle exec sidekiq -q worker2 -c 5 -e production
nohup bundle exec sidekiq -q worker3 -c 5 -e production
nohup bundle exec sidekiq -q worker4 -c 5 -e production
nohup bundle exec sidekiq -q worker5 -c 5 -e production
So, I need to start all of them on EC2 instance, and restart them after next deploy.
Can I use capistrano to do this? or any better way?
Thanks.
You should use something like God, upstart, or runit to keep your sidekiq processes up and running.