gpt4 book ai didi

ruby-on-rails - 用 upstart 脚本守护 sidekiq - 不工作

转载 作者:行者123 更新时间:2023-12-04 18:29:20 27 4
gpt4 key购买 nike

我正在尝试使用 this 之后的两个 Upstart 脚本来守护 sidekiq例子。
基本上,worker 服务会启动固定数量的 sidekiq 服务。

问题是sidekiq 脚本在我开始sidekiq 的代码行处失败。我尝试直接在 bash 中运行该命令,它工作正常。

我尝试了所有不同的注释行,但没有任何效果。

所以我的问题是我做错了什么?我在哪里可以看到错误消息?

这是我修改后的 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"

respawn
respawn limit 15 5

# no "start on", we don't want to automatically start
stop on (stopping workers or runlevel [06])

# TERM and USR1 are sent by sidekiqctl when stopping sidekiq. Without declaring these as normal exit codes, it just respawns.
normal exit 0 TERM USR1

instance $index

script
exec /bin/bash <<EOT
# use syslog for logging
# exec &> /dev/kmsg

# pull in system rbenv
# export HOME=/home/deploy
# source /etc/profile.d/rbenv.sh

cd /home/rails
touch /root/sidekick_has_started
sidekiq -i ${index} -e production
# exec sidekiq -i ${index} -e production
# exec /usr/local/rvm/gems/ruby-2.0.0-p353/gems/sidekiq-3.1.3/bin/sidekiq -i ${index} -e production
touch /root/sidekick_has_started_2
EOT
end script

最佳答案

没错,需要加载 RVM env。试试这个:

.....    
.....

script
exec /bin/bash <<EOT

#export HOME=/home/deploy
source /usr/local/rvm/environments/ruby-2.0.0-p353@global

cd /home/rails
exec sidekiq -i ${index} -e production

.....
.....

它有效吗?

关于ruby-on-rails - 用 upstart 脚本守护 sidekiq - 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24179503/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com