【发布时间】:2012-06-03 02:16:06
【问题描述】:
我无法弄清楚如何让上帝重新启动 resque。
我在 Ubuntu 10.04.3 LTS Linode 切片上有一个 Rails 3.2.2 堆栈。其运行系统 Ruby 1.9.3-p194(无 RVM)。
/etc/init.d/god-service 有一个上帝 init.d 服务,其中包含:
CONF_DIR=/etc/god
GOD_BIN=/var/www/myapp.com/shared/bundle/ruby/1.9.1/bin/god
RUBY_BIN=/usr/local/bin/ruby
RETVAL=0
# Go no further if config directory is missing.
[ -d "$CONF_DIR" ] || exit 0
case "$1" in
start)
# Create pid directory
$RUBY_BIN $GOD_BIN -c $CONF_DIR/master.conf
RETVAL=$?
;;
stop)
$RUBY_BIN $GOD_BIN terminate
RETVAL=$?
;;
restart)
$RUBY_BIN $GOD_BIN terminate
$RUBY_BIN $GOD_BIN -c $CONF_DIR/master.conf
RETVAL=$?
;;
status)
$RUBY_BIN $GOD_BIN status
RETVAL=$?
;;
*)
echo "Usage: god {start|stop|restart|status}"
exit 1
;;
esac
exit $RETVAL
上面的master.conf包含:
load "/var/www/myapp.com/current/config/resque.god"
上面的resque.god包含:
APP_ROOT = "/var/www/myapp.com/current"
God.log_file = "/var/www/myapp.com/shared/log/god.log"
God.watch do |w|
w.name = 'resque'
w.interval = 30.seconds
w.dir = File.expand_path(File.join(File.dirname(__FILE__),'..'))
w.start = "RAILS_ENV=production bundle exec rake resque:work QUEUE=*"
w.uid = "deploy"
w.gid = "deploy"
w.start_grace = 10.seconds
w.log = File.expand_path(File.join(File.dirname(__FILE__), '..','log','resque-worker.log'))
# restart if memory gets too high
w.transition(:up, :restart) do |on|
on.condition(:memory_usage) do |c|
c.above = 200.megabytes
c.times = 2
end
end
# determine the state on startup
w.transition(:init, { true => :up, false => :start }) do |on|
on.condition(:process_running) do |c|
c.running = true
end
end
# determine when process has finished starting
w.transition([:start, :restart], :up) do |on|
on.condition(:process_running) do |c|
c.running = true
c.interval = 5.seconds
end
# failsafe
on.condition(:tries) do |c|
c.times = 5
c.transition = :start
c.interval = 5.seconds
end
end
# start if process is not running
w.transition(:up, :start) do |on|
on.condition(:process_running) do |c|
c.running = false
end
end
end
在deploy.rb我有一个重载任务:
task :reload_god_config do
run "god stop resque"
run "god load #{File.join(deploy_to, 'current', 'config', 'resque.god')}"
run "god start resque"
end
问题是我手动部署还是运行god (stop|start|restart|status) resque,我收到错误消息:
The server is not available (or you do not have permissions to access it)
我尝试将god 安装到系统gem 并在god-service 中指向它:
GOD_BIN=/usr/local/bin/god
但是god start rescue 给出了同样的错误。
但是,我可以通过以下方式启动服务:
sudo /etc/init.d/god-service start
所以我认为这可能是一个权限问题,可能与 init.d 服务归 root 拥有,而 god 是由 deploy 用户从捆绑包中运行的事实有关。
解决此问题的最佳方法是什么?
【问题讨论】:
-
我遇到了同样的问题。你解决了吗?
-
不幸的是,我现在只是在没有上帝的情况下运行我的服务。当我有机会时,我会看看 Bluepill。
-
同样的问题,有人找到解决方案了吗?
-
好的,这是您的配置文件的问题,请检查所有这些文件 + 包含在某处失败并抛出此错误的地方。
标签: ruby-on-rails production-environment resque god