使用 upstart 脚本守护 sidekiq - 不起作用 [英] daemonizing sidekiq with upstart script - is not working

查看:54
本文介绍了使用 upstart 脚本守护 sidekiq - 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to daemonize sidekiq using two upstart scripts following this example. Basically the workers service starts a fixed number of sidekiq services.

问题是 sidekiq 脚本在我启动 sidekiq 的代码行失败.我试过直接在 bash 中运行命令,它工作正常.

The problem is that the sidekiq script fails at the line of code where I am starting sidekiq. I've tried to run the command directly in bash and it works fine.

我尝试了所有不同的注释行,但没有奏效.

I tried all different commented lines and none works.

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

So my question is what am I doing wrong? Where can I see the error messages?

这是我修改过的 sidekiq 脚本:

This is my modified sidekiq script:

# /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.试试这个:

You are right, RVM env are required to be loaded in. Try this:

.....    
.....

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

.....    
.....

有用吗?

这篇关于使用 upstart 脚本守护 sidekiq - 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆