我有一个我想用 monit 监控的自定义服务。当进程失败时,我想将日志复制到共享文件系统并重新启动服务。类似于以下内容,但我不确定是什么。任何提示将不胜感激。
check process pipeline with pidfile /var/run/pipeline.pid
start program = "/sbin/start pipeline"
stop program = "/sbin/stop pipeline"
if 10 restarts within 10 cycles then timeout
# Not sure what to write next
if <service has failed>
restart and
exec "/bin/bash -c 'cp /var/log/upstart/pipeline.log /nfs/logs/`hostname`.`date +'%m-%d-%Y_%H.%M.%S'`.log'"
Run Code Online (Sandbox Code Playgroud)