我有一个服务,它是一个监听端口的服务器:7000。
我想验证服务是否始终处于启动状态,当它失败时我想再次启动它。
我在/etc/monit.d/myserver
中编写了下一个脚本check process myserver with pidfile /var/run/myserver.pid
start program = "/etc/init.d/myserver start" with timeout 5 seconds
stop program = "/etc/init.d/myserver stop" with timeout 5 seconds
if failed host 127.0.0.1 port 7000
protocol HTTP request /testcheck then restart
if 5 restarts within 5 cycles then timeout
但是我注意到即使进程正在运行,它也会重新启动服务,并在日志中提供下一条信息:
EST Dec 18 03:05:13] error : HTTP: error receiving data -- Resource temporarily unavailable
[EST Dec 18 03:05:13] error : 'myserver ' failed protocol test [HTTP] at INET[127.0.0.1:7000] via TCP
[EST Dec 18 03:05:13] info : 'myserver ' trying to restart
[EST Dec 18 03:05:13] info : 'myserver ' stop: /etc/init.d/myserver
[EST Dec 18 03:05:14] info : 'myserver ' start: /etc/init.d/myserver
如何正确检查,以便在服务停止时,它会重新启动它?