我正在尝试通过 upstart 启动 gitlab sidekiq 守护进程。但不幸的是,由于 sidekiq start 自行取消了进程,sidekiq 工作进程似乎被重新生成了:
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
有没有办法“取消妖魔化”rake 任务?(我知道这和这)或者专门运行 gitlab sidekiq 作为 upstart 脚本。这是我目前的工作:
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
我能够修复脚本。由于 sidekiq:start 会自行解除进程,因此我需要将其放入启动后和停止后环境中。
# /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