2

I'm trying start the gitlab sidekiq daemon through upstart. But unfortunately it seems that the sidekiq worker is respawned since sidekiq start deamonizes itself:

Jul 12 17:26:42 git kernel: [370722.042968] init: gitlab-sidekiq main process (28251) terminated with status 1
Jul 12 17:26:42 git kernel: [370722.042997] init: gitlab-sidekiq main process ended, respawning

Is there a way to "undemonise" a rake task? (I'm a aware of this and this) Or specifically run gitlab sidekiq as upstart script. Here's my current work so far:

description "Sidekiq Background Worker for Gitlab"

# no "start on", we don't want to automatically start
start on runlevel [2345]
stop on runlevel [!2345]

# change to match your deployment user
setuid git
setgid git

env HOME=/home/git
env PATH="/usr/local/rvm/gems/ruby-1.9.3-p429@gitlab/bin:/usr/local/rvm/gems/ruby-1.9.3-p429/bin:/usr/local/rvm/gems/ruby-1.9.3-p429@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p429/bin:/usr/local/rvm/bin:/usr/bin:/bin"
env GEM_PATH="/usr/local/rvm/gems/ruby-1.9.3-p429@gitlab:/usr/local/rvm/gems/ruby-1.9.3-p429@global"
env RAILS_ENV="production"
respawn
respawn limit 3 30

script
# this script runs in /bin/sh by default
  cd /home/git/gitlab
  exec bundle exec rake sidekiq:start
end script

1 Answer 1

2

I was able to fix the script. Since sidekiq:start deamonizes itself I needed to put it into a post-start and post-stop environment.

# /etc/init/gitlab-sidekiq.conf - Sidekiq config for gitlab

# use the service command:
#   sudo service gitlab-sidekiq {start,stop,restart,status}

description "Sidekiq Background Worker for Gitlab"

start on runlevel [2345]
stop on runlevel [!2345]

# change to match your deployment user
setuid git
setgid git

env HOME=/home/git
env PATH="/usr/local/rvm/gems/ruby-1.9.3-p429@gitlab/bin:/usr/local/rvm/gems/ruby-1.9.3-p429/bin:/usr/local/rvm/gems/ruby-1.9.3-p429@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p429/bin:/usr/local/rvm/bin:/usr/bin:/bin"
env GEM_PATH="/usr/local/rvm/gems/ruby-1.9.3-p429@gitlab:/usr/local/rvm/gems/ruby-1.9.3-p429@global"
env RAILS_ENV="production"

post-start script
  cd /home/git/gitlab
  exec bundle exec rake sidekiq:start
end script


post-stop script
  cd /home/git/gitlab
  exec bundle exec rake sidekiq:stop
end script

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .