How to use sidekiq and redis in digital ocean?

June 19, 2014 4.4k views
I have a rails app and i would like to use sidekiq for background processing. I have few doubts regarding usage of sidekiq in digital ocean. 1, How can i start ssidekiq in digital ocean ruby on rails droplet? 2, I have read the document explaining the installation of redis in ubuntu, but how can i start redis in the same droplet whenever i restart? 3, Can i start sidekiq from the procfile in rails? If yes, how should i add the start command (e.g., worker: bundle exec sidekiq in heroku). How should i start in digital ocean? 4, If the task is assigned to redis queue and what happens if the redis is restarted? 5, Similarly what happens when sidekiq is restarted when a task is being processed? Please help me.
2 Answers
Hi! There are many ways that you can accomplish all of this. If you'd like to start sidekiq from a procfile, I'd suggest you take a look at Foreman. It allows you to run a procfile simply with:
foreman start
You can install it with:
gem install foreman
Check it out: You could start Redis that way as well, but it probably makes more sense to just have it startup at boot using the init system. If you install it using the following tutorial, init scripts will be included and Redis will automatically start on boot. You can then control it with:
sudo service redis_6379 start
sudo service redis_6379 stop
The number depends on the port you set during the installation. 6379 is the default port setting.
by Etel Sverdlov
This tutorial covers the Redis Installation, some simple Redis operations, and the 5 Redis data types. Redis, developed in 2009, is a flexible, open-source, key value data store that allows users to store vast amounts of data without the limits of a relational database.
Thank you and i would like to know few more thing. If i start of the sidekiq and the app from the procfile, then if i were supposed to push some code changes then the app should be restarted so, what happens for the process that is currently running in the sidekiq? Can i able to run sidekiq separately in the same droplet so that the restarting the app would not affect sidekiq?
  • You can run it completely separately, they provide a sample Upstart script which you can use to start it as a system service:
Have another answer? Share your knowledge.