4

My goal is to have sidekiq start when the server boots up (I'm using EC2 with an auto-scaling group). I know there are a few other posts regarding getting sidekiq to start with upstart on boot, but I don't believe mine has been addressed specifically.

I'm using this wiki - https://github.com/mperham/sidekiq/tree/master/examples/upstart/manage-many and have placed the scripts inside /etc/init/sidekiq.conf and /etc/init/sidekiq-manager.conf.

I've made a couple small modifications as directed in /etc/init/sidekiq.conf, changing:

  • # setuid apps # setgid apps -> replaced apps with ubuntu in both lines, which is the deployment user.

  • export HOME=/home/apps to export HOME=/home/ubuntu

I also have a /etc/sidekiq.conf that includes the following line:

/home/ubuntu/app_dir, 2

Otherwise, these scripts are identical to those included in the referenced repo. I'm getting the following errors in my logs (/var/log/upstart)

/bin/bash: line 19: cd: 2: No such file or directory Could not locate Gemfile

It appears as if it's attempting to change directory somewhere other than /home/ubuntu/app_dir, at which point it's in the wrong directory and cannot find my Gemfile.

Is there somewhere else I need to specify a correct path to my app directory?

Thanks!

s1ack3rhack3r
  • 319
  • 2
  • 12
  • 1
    If you are only using one app on the machine, don't use manage-many. manage-one is simpler. – Mike Perham Aug 16 '14 at 23:44
  • Thanks! That got me on the right track - at this point, my only issue seems to be loading the ruby env in this section of sidekiq.conf: `source /etc/profile.d/rbenv.sh`. I've tried a solution similar to that suggested here in the accepted answer as well: http://stackoverflow.com/questions/24179503/daemonizing-sidekiq-with-upstart-script-is-not-working, but to no avail. My error message is the following: `/bin/bash: line 9: exec: sidekiq: not found` – s1ack3rhack3r Aug 17 '14 at 23:14
  • To be more specific, by "error message" I mean the output that I found in a sidekiq log file in `/var/log/upstart/` – s1ack3rhack3r Aug 17 '14 at 23:23

1 Answers1

1

You can run sidekiq as an upstart job. Making a sidekiq.conf file in /etc/init/ directory and put the upstart code to run sidekiq. Here is the complete script and the guide to make sidekiq upstart job.

After making this job, sidekiq start/stop/restart would be easy with sudo service command.

Ajeet Khan
  • 8,582
  • 8
  • 42
  • 65