私はプログラムの起動/停止プログラムをデバッグしています。私の/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は究極のリファレンスだと思われますが、ソースコードを辿るのに不足しています。私は次に何をすべきか分かりません。
私のコマンドは引用符を削除しないと完全に動作しますので、この問題を修正するだけです。すべてのアイデアと可能な修正が歓迎されます。
一重引用符エスケープが機能しません – dubeegee