系统启动时启动Sidekiq。Ubuntu 14.04。

3

我浏览了整个互联网,但无法做到这一点。需要在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。


nobilik,你解决了这个问题吗? - Jared Menard
@JaredMenard 还没有,但是考虑尝试运行级别。我忙于其他事情。 - nobilik
如果我想到了解决方案,我会在这里发布答案。 - Jared Menard
您IP地址为143.198.54.68,由于运营成本限制,当前对于免费用户的使用频率限制为每个IP每72小时10次对话,如需解除限制,请点击左下角设置图标按钮(手机用户先点击左上角菜单按钮)。 - nobilik
2个回答

0
感谢 Mike Perham 的帮助。我只是使用了错误的脚本。使用 this script,Sidekiq 将在启动时开始运行。

0

startup事件在系统启动时触发,此时无法访问可写文件系统或网络,可能会尝试启动,但会崩溃甚至无法记录日志。

稍后再运行它,例如在运行级别2或其他依赖项已启动的自定义事件(redis、数据库等)中运行。

还要将# rvm注释掉,那不是一个命令,而是下一行带有source ...标签。


对于 #rvm 我已经看过了,谢谢。其他的事情我会尝试一下。 - nobilik

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接