Node.js(sudo)和monit
我创建了一个upstart脚本以守护juggernaut(一个node.js应用程序)
upstart脚本如下
description "juggernaut server"
author "panojsee"
start on startup
stop on shutdown
script
# We found $HOME is needed. Without it, we ran into problems
#export HOME="/home/ubuntu/src/juggernaut"
chdir /home/ubuntu/src/juggernaut
exec sudo /usr/bin/node server.js 2>&1 >> /var/log/node.log
end script
如您所见,我想用sudo运行节点(这样我就可以使用Flash套接字)。
我的monit脚本如下:
设置logfile /var/log/monit.log
check host juggernaut with address 127.0.0.1
start program = "/sbin/start juggernaut"
stop program = "/sbin/stop juggernaut"
if failed port 8080 protocol HTTP
request /
with timeout 10 seconds
then restart
Monit不允许我启动程序=“sudo / sbin / start juggernaut”
一旦我杀死juggernaut(节点)然后monit尝试重新启动它,但死了以下消息。
[UTC Feb 3 22:48:25] error : 'nodejs' failed, cannot open a connection to INET[127.0.0.1:8080] via TCP
[UTC Feb 3 22:48:25] info : 'nodejs' trying to restart
[UTC Feb 3 22:48:25] info : 'nodejs' stop: sudo
[UTC Feb 3 22:48:25] error : Error: Could not execute sudo
[UTC Feb 3 22:48:25] info : 'nodejs' start: sudo
有什么线索我怎么告诉monit执行sudo命令?
没有找到相关结果
已邀请:
3 个回复
荤碗
锑寝粒
购藏盗码韦
)。 我发现这个答案对于搞清楚monit行为非常有帮助。