2012-08-23 17 views
0

我在嘗試設置Monit來管理Resque工作人員,但未能開始說/home/deployer/.rbenv/shims/bundle: line 4: exec: rbenv: not found 我檢查到它運行的命令爲deployer用戶,如果我複製並粘貼該命令直接通過SSH一切正常。以下是我的Monit配置。謝謝!在RBenv設置下用Monit管理Resque工人

 
check process resque_worker_1 
    with pidfile CURRENT_PATH/tmp/pids/resque_worker_1.pid 
    start program = "/usr/bin/env HOME=/home/deployer RACK_ENV=production PATH=/home/deployer/.rbenv/shims:/usr/local/bin:/usr/local/ruby/bin:/usr/bin:/bin:$PATH /bin/sh -l -c 'cd CURRENT_PATH; bundle exec rake environment resque:work RAILS_ENV=production QUEUE=high,normal,low VERBOSE=1 PIDFILE=CURRENT_PATH/tmp/pids/resque_worker_1.pid >> CURRENT_PATH/log/resque_worker_.log 2>&1'" 
    as uid deployer and gid admin 
    stop program = "/bin/sh -c 'cd CURRENT_PATH && kill -9 $(cat tmp/pids/resque_worker_1.pid) && rm -f tmp/pids/resque_worker_1.pid; exit 0;'" 
    as uid deployer and gid admin 
    if totalmem is greater than 300 MB for 10 cycles then restart # eating up memory? 
    group resque_workers 

回答

1

我不確定這是否有幫助,但在我的monitrc啓動行中,我必須首先su到我想運行的用戶。我還沒有嘗試過使用uid和gid標誌來了解它是否正常工作,因此這可能是一個鵝的答案。

我記得你有同樣的問題,雖然......一切都從命令行工作,但不是當monit會做它的事情。

例如,在我的monitrc,我監測arsendmail下列要求:

 
# arsendmail_rails3 
# daemon that watches and sends mail from the rails app 
check process ar_sendmail with pidfile /var/www/rak/log/ar_sendmail.pid 
start program "/bin/su - mike && /bin/bash -c 'cd /var/www/rak && ar_sendmail_rails3 -b1000 -d -e production'" 
stop program "/bin/ps -ef | /bin/grep ar_sendmail_rails3 | /bin/grep -v grep | /usr/bin/awk '{ /usr/bin/print $2}' | /usr/bin/xargs /bin/kill -9" 
0

這爲我工作。

由pidfile <%= resque_pid%檢查處理app_resque_worker> 啓動程序=「/ USR/bin中/ env的HOME = /家庭/ subcaster RACK_ENV =生產PATH = /家庭/ subcaster/.rvm /紅寶石/紅寶石-2.0/usr/local/ruby​​/bin:/ usr/bin:/ bin:$ PATH/bin/sh -l -c \'cd <% %>;捆綁EXEC耙環境resque:工作RAILS_ENV =生產BACKGROUND =是QUEUE = * PIDFILE = <%= resque_pid%> \' 「

停止程序=」 殺-9 cat <%= resque_pid%> & & RM -f <%= resque_pid%>「

如果totalmem大於2000 MB的10個週期,然後重新啓動

1

我看到該主題是在2012年創建的,但我有一個類似的問題,這個線程是谷歌排名最高。

問題是使用受限制的env(env -i PATH =/bin:/ usr/bin:/ sbin:/ usr/sbin/bin/sh來模擬)的monit啓動命令。

要在rbenv中使用monit,必須在bundle exec命令之前指定正確的路徑。 。

PATH = /家庭/ [USER]/rbenv /斌:/家庭/ [USER]/rbenv /墊片:$ PATH捆綁高管...

例與麒麟:

check process unicorn_dev with pidfile /home/wizville/app/dev.wizville.fr/shared/pids/unicorn.pid 
    group dev 
    start program = "/bin/bash -c 'cd /home/wizville/app/dev.wizville.fr/current && PATH=/home/wizville/.rbenv/bin:/home/wizville/.rbenv/shims:$PATH bundle exec unicorn -c config/unicorn.rb -D'" as uid "wizville" 
    stop program = "/bin/bash -c 'kill -s QUIT `cat /home/wizville/app/dev.wizville.fr/shared/pids/unicorn.pid`'" 
    depends on mysql