2013-07-30 4 views
6

monit 시작/중지 프로그램 명령문을 디버깅합니다. 내 /etc/monit.conf 파일에서 내 start program 문은 다음과 같습니다monit 시작 프로그램 명령에서 따옴표를 제거합니다.

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

$ 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 ' 

이이 /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'"" 

그러나 sudo monit -v monitor node을 실행하면 다른 명령, 동일한 exce가 표시됩니다. 내부 따옴표와 PT는을 제거 : 나는 MONIT 문서에서 이것에 대해 아무것도 찾을 수 없습니다

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 

. 문서 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