Using systemd to Manage Multiple Sidekiq Processes

Dan Sadaka edited this page Nov 23, 2016 · 2 revisions

Though systemd is mentioned in this Wiki as one of the recommended approaches to managing Sidekiq processes, it is not as well documented as Upstart. This was fine until Ubuntu 15.04+ where systemd is now the default and Upstart is not even included.

So, I set about finding a way to simply do what workers.conf does in the Upstart world. That is, allow a single command to fire up and shutdown the SideKiq processes. It wasn't as easy as I'd hoped, due to a lack of any clear examples and conflicting opinions. However, in the end, it turns out to be not too ugly.

  1. Install the setup files from:
  2. Enable up to six processes (for more, see notes in /lib/systemd/system/sidekiq-static.service)
  3. start processes
    • sudo systemctl start
  4. quiet processes
    • sudo pgrep -u -f 'sidekiq' | xargs kill -USR1 | exit 0
  5. stop processes
    • sudo systemctl stop -- $(systemctl show -p Wants|cut -d= -f2)"

Note that you may also interact with any process individually:

sudo systemctl {start, stop, restart} sidekiq@n.service

I would credit references but there were so many. You guys know who you are though! :-)

If anyone can come up with better ways to quiet and stop, please comment.