2013-07-30 11 views
6

私はプログラムの起動/停止プログラムをデバッグしています。私の/etc/monit.confファイルでは、私のstart programの文は次のようになります。私はmonitは、プログラムの開始コマンドから引用符を削除します。

$ sudo su 
# env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/sh 
# /bin/su -c '/usr/bin/env APP_ENV=development; /home/ec2-user/local/bin/node /home/ec2-user/example.com/current/api.js start &> /tmp/monit.out ' 

がこれを実行すると、シェルでテストしてみた

check process node with pidfile /home/ec2-user/blah/node.pid 
    start program = "/bin/su -c 'export APP_ENV=development; /home/ec2-user/local/bin/node /home/ec2-user/example.com/current/api.js start &> /tmp/monit.out ' " 
    stop program = "/bin/su -c '/home/ec2-user/local/bin/node /home/ec2-user/example.com/current/api.js stop'"" 

/tmp/monit.outファイルに正しい出力を返します。

Starting nodejs daemon... 
nodejs daemon started. PID: 16408 

しかし、sudo monit -v monitor nodeを実行すると、異なるコマンド、同じexce内側の単一引用符でPTがを削除:

The service list contains the following entries: 

Process Name   = node 
Pid file    = /home/ec2-user/blah/node.pid 
Monitoring mode  = active 
Start program  = '/bin/su -c export APP_ENV=development; /home/ec2-user/local/bin/node /home/ec2-user/example.com/current/api.js start &> /tmp/monit.out ' timeout 30 second(s) 
Stop program   = '/bin/su -c /home/ec2-user/local/bin/node /home/ec2-user/example.com/current/api.js stop' timeout 30 second(s) 
Existence   = if does not exist 1 times within 1 cycle(s) then restart else if succeeded 1 times within 1 cycle(s) then alert 
Pid     = if changed 1 times within 1 cycle(s) then alert 
Ppid     = if changed 1 times within 1 cycle(s) then alert 

System Name   = system_ip-xx-xx-xx-xx.ec2.internal 
Monitoring mode  = active 

私はMONITのドキュメントでこのことについて何かを見つけることができません。ドキュメントhereは究極のリファレンスだと思われますが、ソースコードを辿るのに不足しています。私は次に何をすべきか分かりません。

私のコマンドは引用符を削除しないと完全に動作しますので、この問題を修正するだけです。すべてのアイデアと可能な修正が歓迎されます。

答えて

2

それはあなたが単一引用符文字をエスケープする必要はありません、それは(私がmisleadedた)いくつかの誤解を招くため、それにもかかわらず、私はそれが重要見つける、

かなり遅れての答えです。それを試してみてください。

check process fake_proc 
    with pidfile /tmp/test_pid 
    start = "/bin/bash -c 'echo $$ > /tmp/test_pid'" 
    stop = "echo stop > /tmp/test_pid" 

それはしかしtest_pidファイルが作成され、開始したプロセスとして示されていないでしょう。 ; sleep xxを追加してプロセスをキャッチし、そのプロパティを調べます。

問題は、env固有の問題が原因で発生している可能性があります。

0

"プログラムの開始"と "プログラムの停止"に関するコマンドをシェルスクリプトに入れて実行可能にし、そのアドレスをmonitに与えます。

また、スラッシュを使用して、単一引用符をエスケープしてみてください

\」

(私はそれが動作するかどうか私は知らない試していません)。

+3

一重引用符エスケープが機能しません – dubeegee

関連する問題