Ruby on rails “上帝给了我们一个开始”;“服务器不可用”;
我很难弄明白如何让上帝重新启动resque 我在Ubuntu10.04.3 LTS Linode切片上有一个Rails 3.2.2堆栈。其运行系统为Ruby 1.9.3-p194(无RVM) 在Ruby on rails “上帝给了我们一个开始”;“服务器不可用”;,ruby-on-rails,production-environment,resque,god,Ruby On Rails,Production Environment,Resque,God,我很难弄明白如何让上帝重新启动resque 我在Ubuntu10.04.3 LTS Linode切片上有一个Rails 3.2.2堆栈。其运行系统为Ruby 1.9.3-p194(无RVM) 在/etc/init.d/God service有一个God 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 RE
/etc/init.d/God service
有一个God 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
load "/var/www/myapp.com/current/config/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
上面的master.conf
包含:
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
load "/var/www/myapp.com/current/config/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
resque.上面的上帝包含:
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
load "/var/www/myapp.com/current/config/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(停止|启动|重新启动|状态)resque
,我都会收到错误消息:
The server is not available (or you do not have permissions to access it)
我尝试将上帝
安装到系统gems,并在上帝服务
中指向它:
GOD_BIN=/usr/local/bin/god
但是上帝开始拯救
给出了同样的错误
但是,我可以通过以下操作启动服务:
sudo /etc/init.d/god-service start
因此,我认为这可能是一个权限问题,可能与init.d服务归root
所有,而god由deploy
用户从包中运行这一事实有关
解决此问题的最佳方法是什么?好的,这是您的配置文件的问题,请检查所有配置文件+包含失败的地方,并向您抛出此错误。我检查了我的,并修复了一些错误后,它的工作完美 好的,这是您的配置文件的问题,请检查所有配置文件+包含失败的地方,并向您抛出此错误。我检查了我的,并修复了一些错误后,它的工作完美 您正在以不同的用户身份运行god服务(很有可能是root用户)
还可以查看:您正在以不同的用户身份运行god服务(很有可能是root用户)
还要检查:首先,您可以使用“god--version”命令检查您的机器中是否安装了god。如果可用,请尝试使用-D选项运行一些god脚本。例如“god-c sample.god-D”,它将在控制台的标准输出中为您提供一些类型的错误消息,具体问题在哪里。当我尝试在没有“-D”选项的情况下运行commmand时,我也遇到了同样的错误。然后,当我尝试使用“-D”模式时,有人告诉我某个文件夹写入权限问题,我可以找到并修复它。首先,您可以使用“god--version”命令检查您的计算机中是否安装了god。如果可用,请尝试使用-D选项运行一些god脚本。例如“god-c sample.god-D”,它将在控制台的标准输出中为您提供一些类型的错误消息,具体问题在哪里。当我尝试在没有“-D”选项的情况下运行commmand时,我也遇到了同样的错误。然后,当我尝试使用“-D”模式时,有人告诉我某个文件夹写入权限问题,我可以找到并解决它。我也遇到了同样的问题。你能解决吗?不幸的是,我现在只是在没有上帝的情况下运行我的服务。当我有机会的时候,我会看看Bluepill。同样的问题,有人找到了解决方案吗?好的,这是你的配置文件的问题,检查它们所有的配置文件+它失败的地方抛出这个错误。我也有同样的问题。你能解决吗?不幸的是,我现在只是在没有上帝的情况下运行我的服务。当我有机会的时候,我会看看Bluepill。同样的问题,有人找到了解决方案吗?好的,这是你的配置文件的问题,检查所有的配置文件+它失败的地方会抛出这个错误。@Rubytastic你能详细说明你的答案吗?只要检查语法配置文件的语法中一定有错误,这就是我的意思。就我而言,这解决了问题。既然是从上帝那里转换过来的。@Rubytastic你能详细说明你的答案吗?只要检查一下语法,配置文件的语法肯定有错误,这就是我的意思。就我而言,这解决了问题。自从从上帝那里转换过来。