【问题标题】:God resque start gives "The server is not available"God resque start 给出“服务器不可用”
【发布时间】: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


【解决方案1】:

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

另请查看:God not running: The server is not available (or you do not have permissions to access it)

【讨论】:

    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

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

      【讨论】:

      • @Rubytastic 你能详细说明你的答案吗??
      • 只检查语法,配置文件的语法肯定有错误,我就是这么说的。就我而言,这解决了问题。自从转神。
      猜你喜欢
      • 1970-01-01
      • 2013-05-13
      • 2013-02-16
      • 2015-01-19
      • 1970-01-01
      • 2020-08-23
      • 2012-08-28
      • 2015-08-25
      • 1970-01-01
      相关资源
      最近更新 更多