简体   繁体   English

有没有办法在 nginx 没有响应状态 200 时自动重启 nginx

[英]Is there a way to automatically restart nginx with monit when it doesnt respond with status 200

Is there a way to automatically restart nginx with monit when it doesnt respond with status 200有没有办法在 nginx 没有响应状态 200 时自动重启 nginx

The server seems to handle most of the requests but tends to lock up for a minute or two when it gets overwhelmed with requests.服务器似乎处理了大部分请求,但是当它被请求淹没时往往会锁定一两分钟。 So I would like to have it check if the request responds to 504/502 to restart nginx所以我想让它检查请求是否响应 504/502 以重新启动 nginx

A simple sample to handle nginx is available from https://mmonit.com/wiki/Monit/ConfigurationExamples#NginX and from https://www.mmonit.com/monit/documentation/monit.html#CONFIGURATION-EXAMPLES some other samples are available.处理 nginx 的简单示例可从https://mmonit.com/wiki/Monit/ConfigurationExamples#NginXhttps://www.mmonit.com/monit/documentation/monit.html#CONFIGURATION-EXAMPLES获得其他一些示例可用。

And there are general information about handling the http status code from https://www.mmonit.com/monit/documentation/monit.html#HTTP并且有关于处理来自https://www.mmonit.com/monit/documentation/monit.html#HTTP的 http 状态码的一般信息

You can setup the Monit to test in shorter intervals, but one or two minutes is a good interval size (in general, from my point of view).您可以将 Monit 设置为以较短的间隔进行测试,但一两分钟是一个很好的间隔大小(从我的角度来看,一般来说)。 In the Monit configuration monitrc file you can use a shorter interval.在 Monit 配置 monitrc 文件中,您可以使用更短的时间间隔。

set daemon 60 # check services at 60 seconds intervals set daemon 60 # 每隔 60 秒检查一次服务

But you should not use a interval below 30 seconds (I prefer 60 seconds).但是你不应该使用低于 30 秒的时间间隔(我更喜欢 60 秒)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM