在系统启动时启动 Sidekiq。 Ubuntu 14.04
Start Sidekiq on system boot up. Ubuntu 14.04
我阅读了整个互联网,但做不到。需要在 VDS (Ubuntu 14.04) 启动时启动 Sidekiq。我发现并使用了这个:
# /etc/init/sidekiq.conf - Sidekiq config
# This example config should work with Ubuntu 12.04+. It
# allows you to manage multiple Sidekiq instances with
# Upstart, Ubuntu's native service management tool.
#
# See workers.conf for how to manage all Sidekiq instances at once.
#
# Save this config as /etc/init/sidekiq.conf then manage sidekiq with:
# sudo start sidekiq index=0
# sudo stop sidekiq index=0
# sudo status sidekiq index=0
#
# Hack Upstart's reload command to 'quiet' Sidekiq:
#
# sudo reload sidekiq index=0
#
# or use the service command:
# sudo service sidekiq {start,stop,restart,status}
#
description "Sidekiq Background Worker"
start on startup
#start on runlevel [2345]
stop on runlevel [06]
#start on startup
# change to match your deployment user
setuid me
setgid me
env HOME=/home/me
respawn
respawn limit 3 30
# TERM is sent by sidekiqctl when stopping sidekiq. Without declaring these as
# normal exit codes, it just respawns.
normal exit 0 TERM
# Older versions of Upstart might not support the reload command and need
# this commented out.
reload signal USR1
instance $index
script
# this script runs in /bin/sh by default
# respawn as bash so we can source in rbenv
exec /bin/bash <<'EOT'
# Pick your poison :) Or none if you're using a system wide installed Ruby.
# rbenv
# source /home/apps/.bash_profile
# OR
# source /home/apps/.profile
# OR system:
# source /etc/profile.d/rbenv.sh
#
rvm
source /usr/local/rvm/scripts/rvm
# Logs out to /var/log/upstart/sidekiq.log by default
cd /var/www/vk_c_watcher/code
exec bundle exec sidekiq -i ${index} -e production
EOT
end script
添加后我可以用 start sidekiq app="/var/www/vk_c_watcher/code" index=0
启动 Sidekiq。但是在重新启动时,进程列表中没有 Sidekiq。
startup
事件在系统启动时触发,此时没有可写文件系统或网络可访问,可能它确实尝试启动,但崩溃甚至无法记录。
运行稍后,例如在运行级别 2 或在其他依赖项启动时触发的某些自定义事件(redis、您的数据库等)
同时注释掉 # rvm
回来,那不是命令,而是下一行的标签 source ...
。
感谢 Mike Perham 的帮助。我只是使用了错误的脚本。 this script Sidekiq 在启动时启动。
我阅读了整个互联网,但做不到。需要在 VDS (Ubuntu 14.04) 启动时启动 Sidekiq。我发现并使用了这个:
# /etc/init/sidekiq.conf - Sidekiq config
# This example config should work with Ubuntu 12.04+. It
# allows you to manage multiple Sidekiq instances with
# Upstart, Ubuntu's native service management tool.
#
# See workers.conf for how to manage all Sidekiq instances at once.
#
# Save this config as /etc/init/sidekiq.conf then manage sidekiq with:
# sudo start sidekiq index=0
# sudo stop sidekiq index=0
# sudo status sidekiq index=0
#
# Hack Upstart's reload command to 'quiet' Sidekiq:
#
# sudo reload sidekiq index=0
#
# or use the service command:
# sudo service sidekiq {start,stop,restart,status}
#
description "Sidekiq Background Worker"
start on startup
#start on runlevel [2345]
stop on runlevel [06]
#start on startup
# change to match your deployment user
setuid me
setgid me
env HOME=/home/me
respawn
respawn limit 3 30
# TERM is sent by sidekiqctl when stopping sidekiq. Without declaring these as
# normal exit codes, it just respawns.
normal exit 0 TERM
# Older versions of Upstart might not support the reload command and need
# this commented out.
reload signal USR1
instance $index
script
# this script runs in /bin/sh by default
# respawn as bash so we can source in rbenv
exec /bin/bash <<'EOT'
# Pick your poison :) Or none if you're using a system wide installed Ruby.
# rbenv
# source /home/apps/.bash_profile
# OR
# source /home/apps/.profile
# OR system:
# source /etc/profile.d/rbenv.sh
#
rvm
source /usr/local/rvm/scripts/rvm
# Logs out to /var/log/upstart/sidekiq.log by default
cd /var/www/vk_c_watcher/code
exec bundle exec sidekiq -i ${index} -e production
EOT
end script
添加后我可以用 start sidekiq app="/var/www/vk_c_watcher/code" index=0
启动 Sidekiq。但是在重新启动时,进程列表中没有 Sidekiq。
startup
事件在系统启动时触发,此时没有可写文件系统或网络可访问,可能它确实尝试启动,但崩溃甚至无法记录。
运行稍后,例如在运行级别 2 或在其他依赖项启动时触发的某些自定义事件(redis、您的数据库等)
同时注释掉 # rvm
回来,那不是命令,而是下一行的标签 source ...
。
感谢 Mike Perham 的帮助。我只是使用了错误的脚本。 this script Sidekiq 在启动时启动。