2016-03-29 67 views
0

基本上,monit在文件“product_id”准备就绪时启动进程“CAD”。我的配置如下:Monit等待文件启动进程?

check file product_id with path /etc/platform/product_id 
    if does not exist then alert 

check process cad with pidfile /var/run/cad.pid 
    depends on product_id 
    start = "/bin/sh -c 'cd /home/root/cad/scripts;./run-cad.sh 2>&1 | logger -t CAD'" with timeout 120 seconds 
    stop = "/bin/sh -c 'cd /home/root/cad/scripts;./stop-cad.sh 2>&1 | logger -t CAD'" 

我期待“monit”调用“开始”,直到文件可用。但它似乎重启了每个周期的过程(停止和开始)。

这里有什么配置错吗?

感谢任何帮助。

+0

为什么你使用“检查过程”块?查看文档,如果文件不存在于“检查文件”块中,您似乎可以执行脚本 https://mmonit.com/monit/documentation/monit.html#EXISTENCE-TESTING – alex9311

回答

0

重启每个周期的原因是因为product_id文件尚未准备就绪。如果检查失败,依赖于product_id的任何事情都将重新启动。

我会建议编写一个脚本,检查product_id是否存在,如果它存在,就启动CAD。然后,您可以在monit中从“检查程序”块中运行此脚本。