我的服务器上有VestaCp和nginx,我想在服务停止时重新启动它。
例如,有时nginx会停止并需要重新启动manually.So,此时我的网站无法访问。
发布于 2016-01-29 05:46:28
我推荐Monit软件。它是免费的,你可以在互联网上找到很多例子。
Idk如果Centos在yum install monit上有这个包,它肯定在Debian repos上。
在web服务器内部运行的web服务的基本监视器应在所需端口使用http检查,即80 front nginx或8080 apache2 reverse_proxy。
git examples上的示例
# nginx
check process nginx with pidfile /opt/nginx/logs/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
if failed host 127.0.0.1 port 80 then restart
if cpu is greater than 40% for 2 cycles then alert
if cpu > 60% for 5 cycles then restart
if 10 restarts within 10 cycles then timeoutnginx和alert的最低配置:
# email alerts
set mailserver localhost
set mail-format { from: monit@localhost OR you@your-domain.com }
set alert your-email@your-domain.com
# nginx
check process nginx with pidfile /opt/nginx/logs/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
if failed host 127.0.0.1 port 80 then restart
if failed host 127.0.0.1 port 80 then alert它的作用是不言而喻的。
通常,您应该为您监视的每个服务放置单独的文件,并保持它们的整洁。此外,示例服务是提供者,您只需将它们放在正确的文件夹中即可启用它们。
在that link上有一个包含快速示例的很好的文档
我使用它,它真的很酷。如你所见,你可以运行许多程序,以避免任何事件触发器。你可以观看pids,港口和许多其他的东西。
你可以询问nginx,当然你也可以在vesta服务上观看。Vesta管理面板在另一个nginx进程中运行,该进程不是由安装的nginx服务处理的,因为这个进程用于主机上的nginx代理。
因此,这里有2个nginx进程,您将同时看到8083和80 (以及ssl的443 )
我在过去通过pid监控apache2时遇到了一些问题,所以http检查更好。如果listen正在运行。
祝你好运。
https://stackoverflow.com/questions/34246299
复制相似问题