繁体   English   中英

使用God Monitor Unicorn进行轨道操作但权限错误

[英]Using God monitor unicorn for rails but permission error

我是God新手。 我正在尝试使用God来监视运行我的rails应用程序的unicorn过程。

这是我的上帝档案:

rails_env = ENV["RAILS_ENV"]
APP_ROOT = '/home/deployer/deploy/myproject'
RAILS_ROOT = "#{APP_ROOT}/current"

God.watch do |w|
  w.name = "myproject"
  w.interval = 30.seconds
  w.dir = RAILS_ROOT

  w.start = "cd #{RAILS_ROOT} && bundle exec unicorn_rails -E #{rails_env} -c #{RAILS_ROOT}/config/unicorn.rb -D"
  w.stop = "kill -s QUIT `cat #{RAILS_ROOT}/tmp/pids/unicorn.pid`"
  w.restart = "kill -s USR2 `cat #{RAILS_ROOT}/tmp/pids/unicorn.pid`"

  w.start_grace = 20.seconds
  w.restart_grace = 20.seconds
  w.pid_file = "#{RAILS_ROOT}/tmp/pids/unicorn.pid"
  w.log = "#{RAILS_ROOT}/log/unicorn.god.log"

  w.uid = 'deployer'
  w.gid = 'staff'

  w.behavior(:clean_pid_file)

  w.start_if do |start|
    start.condition(:process_running) do |c|
      c.interval = 5.seconds
      c.running = false
    end
  end

  w.restart_if do |restart|
    restart.condition(:memory_usage) do |c|
      c.above = 300.megabytes
      c.times = [3, 5] # 3 out of 5 intervals
    end

    restart.condition(:cpu_usage) do |c|
      c.above = 50.percent
      c.times = 5
end

结束

但是当我空运行以使用god -c config/unicorn.god -D测试配置文件是否有效时,出现以下错误:

$ god -c config/unicorn.god -D
I [2013-02-07 23:51:23]  INFO: Loading config/unicorn.god
I [2013-02-07 23:51:23]  INFO: Syslog enabled.
I [2013-02-07 23:51:23]  INFO: Using pid file directory: /home/deployer/.god/pids
E [2013-02-07 23:51:23] ERROR: PID file directory '/home/deployer/deploy/myproject/current/tmp/pids' is not writable by deployer
E [2013-02-07 23:51:23] ERROR: Log directory '/home/deployer/deploy/myproject/current/log' is not writable by deployer
E [2013-02-07 23:51:23] ERROR: Task 'myproject' is not valid (see above)

但是实际上,我已经允许用户deployer允许这两个目录:

~/deploy/myproject/current$ ls -l
lrwxrwxrwx 1 deployer staff   42 Feb  7 23:24 log -> /home/deployer/deploy/myproject/shared/log

~/deploy/myproject/current/tmp$ ls -l
lrwxrwxrwx 1 deployer staff   43 Feb  7 23:24 pids -> /home/deployer/deploy/myproject/shared/pids

而且God进程也在deployer程序下运行:

$ ps -ef | grep god
deployer   381     1  5 00:20 pts/0    00:00:00 /usr/local/rvm/gems/ruby-1.9.3-p327-falcon@global/bin/god

这是为什么?

我有一个类似的问题。 当我删除w.gid行时,一切正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM