【问题标题】:Sidekiq not running at startup of passenger server in Rails 4.1.6 app在 Rails 4.1.6 应用程序中启动乘客服务器时 Sidekiq 未运行
【发布时间】:2014-11-17 15:41:48
【问题描述】:

在我们的暂存应用程序上启动服务器后,我需要运行 Sidekiq。我们移至 Rackspace 上的另一个服务器实例,以更好地反映我们的生产条件。

应用程序开始于

passenger start --nginx-config-template nginx.conf.erb --address 127.0.0.1 -p 3002 --daemonize

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 mange sidekiq with:
# sudo start sidekiq index=0
# sudo stop sidekiq index=0
# sudo status sidekiq index=0
#
# or use the service command:
# sudo service sidekiq {start,stop,restart,status}
#
description "Sidekiq Background Worker"
# no "start on", we don't want to automatically start
stop on (stopping workers or runlevel [06])
# change to match your deployment user
setuid root
setgid root
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
instance $index
script
# this script runs in /bin/sh by default
# respawn as bash so we can source in rbenv
exec /bin/bash <<EOT
# use syslog for logging
exec &> /dev/kmsg
# pull in system rbenv
export HOME=/root
source /etc/profile.d/rbenv.sh
cd /srv/monolith
exec bin/sidekiq -i ${index} -e staging
EOT
end script

和workers.conf

# /etc/init/workers.conf - manage a set of Sidekiqs
# 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 sidekiq.conf for how to manage a single Sidekiq instance.
#
# Use "stop workers" to stop all Sidekiq instances.
# Use "start workers" to start all instances.
# Use "restart workers" to restart all instances.
# Crazy, right?
#
description "manages the set of sidekiq processes"
# This starts upon bootup and stops on shutdown
start on runlevel [2345]
stop on runlevel [06]
# Set this to the number of Sidekiq processes you want
# to run on this machine
env NUM_WORKERS=2
pre-start script
for i in `seq 0 $((${NUM_WORKERS} - 1))`
do
start sidekiq index=$i
done
end script

当我进入服务器并尝试service sidekiq start index=0service sidekiq status index=0 时,它找不到服务,但如果我运行bundle exec sidekiq -e staging,sidekiq 会启动并顺利通过作业队列。不幸的是,一旦我关闭了 ssh 会话,sidekiq 就会找到杀死自己的方法。

如何确保启动服务器时 sidekiq 运行,并且如果出现问题,如使用 upstart 运行 sidekiq 中所述,它会自行重启?

谢谢。

【问题讨论】:

    标签: ruby-on-rails nginx passenger background-process sidekiq


    【解决方案1】:

    为了将 Sidekiq 作为服务运行,您应该将名为“sidekiq”的脚本放入

    /etc/init.d

    ,而不是 /etc/init

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多