2

我无法弄清楚如何让上帝重新启动 resque。

我在 Ubuntu 10.04.3 LTS Linode 切片上有一个 Rails 3.2.2 堆栈。其运行系统 Ruby 1.9.3-p194(无 RVM)。

有一个上帝 init.d 服务,/etc/init.d/god-service其中包含:

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

root因此,我认为,这可能是一个权限问题,可能与 init.d 服务归用户所有,并且 God 由用户从捆绑包中运行的事实有关deploy

解决这个问题的最佳方法是什么?

4

3 回答 3

0

您正在以不同的用户身份运行上帝服务(很有可能是 root)。

另请查看:上帝未运行:服务器不可用(或您无权访问它)

于 2015-03-12T15:20:28.583 回答
0

首先你使用“god --version”命令检查你是否在你的机器上安装了god。如果它可用,只需尝试使用 -D 选项运行一些神脚本。示例“god -c sample.god -D”它将在控制台的标准输出中为您提供某种类型的错误消息,确切的问题在哪里。当我尝试在没有“-D”选项的情况下运行命令时,我也遇到了同样的错误。然后当我尝试使用“-D”模式时,它被告知一些文件夹写入权限问题,我可以找到它并修复它。

于 2019-05-13T10:48:48.027 回答
-3

好的,这是您的配置文件的问题,请检查所有这些文件 + 包含失败的地方,它会向您抛出此错误。我检查了我的并修复了一些错误,之后它工作得很好!

于 2012-07-20T23:40:22.707 回答