Skip to main content

Does anyone have tips on setting up redis and sidekiq on a Digital Ocean ubuntu 16.04 droplet?

Rails • Asked by Lance Williams

Lance Williams (3,130 XP) on

I have no trouble setting up redis but for some reason I can't get sidekiq to work. I can get sidekiq and redis to work locally on a mac using brew but not on a Digital Ocean Ubuntu 16.04 server.

I'm currently using sucker_punch for running transactional email jobs but I would love to figure out how to set up Redis and Sidekiq on a Digital Ocean Droplet.

Does anyone have any tips or resources you've used to set this up?

Chris Oliver (167,510 XP) on

Basically at this point now, you'll need to use systemd to manage Sidekiq. It will make sure it starts or if it dies, it will restart it. This is nice, but kind of confusing sometimes how to get it setup.

I have this in /etc/systemd/system/sidekiq.service and you can enable it and manage it using the commands at the top there.

# systemd unit file for CentOS 7, Ubuntu 15.04
# Customize this file based on your bundler location, app directory, etc.
# Put this in /usr/lib/systemd/system (CentOS) or /lib/systemd/system (Ubuntu).
# Run:
#   - systemctl enable sidekiq
#   - systemctl {start,stop,restart} sidekiq
# This file corresponds to a single Sidekiq process.  Add multiple copies
# to run multiple processes (sidekiq-1, sidekiq-2, etc).
# See Inspeqtor's Systemd wiki page for more detail about Systemd:
# start us only once the network and logging subsystems are available,
# consider adding redis-server.service if Redis is local and systemd-managed.

# See these pages for lots of options:
# If you use rbenv:
ExecStart=/home/deploy/.rbenv/shims/bundle exec "sidekiq -e production"

# if we crash, restart

# output goes to /var/log/syslog

# This will default to "bundler" if we don't specify it


Not that you'll need to change the WorkingDirectory option for the location of your app and this assumes you're using rbenv on your server for running Ruby.

shakycode (5,400 XP) on

Chris answered this well, but there's also another option of using the God gem to manage sidekiq which I believe is based off of bluepill. Either way will work, but systemd can handle this as Chris mentioned.

Chris Oliver (167,510 XP) on

Yeah, there's a few options like that. I like not having to add another dependency, plus this is nice if you're already us it to run things like Redis, etc.

Jack (6,490 XP) on

Not sure what you're usage is, but unless you're doing lots of (heavy) backgrounding I would stick with sucker_punch. Sidekiq adds quite a lot of extras which I am not sure is worth the time.

Now if you just want to learn how to do it, I am happy to give some pointers though :)

Edit: Ah, lots of valuable stuff already . 👍

Lance Williams (3,130 XP) on

Thanks for the helpful insight. I'll definitely do some set up practice on a droplet to test everything out. Yeah, I was struggling with the systemd configuration file. This helps tremendously.

And Jack thanks for pointing out the reason maybe to just stick with sucker_punch. I'll test it all out and see what makes the most sense.

Shakycode, I'll definitely take a look at the God gem as well.

I was mainly just frustrated that I couldn't figure out the Sidekiq setup.

Thanks for all the pointers!

Login or create an account to join the conversation.