简体   繁体   中英

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

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

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.

And there are general information about handling the http status code from https://www.mmonit.com/monit/documentation/monit.html#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). In the Monit configuration monitrc file you can use a shorter interval.

set daemon 60 # check services at 60 seconds intervals

But you should not use a interval below 30 seconds (I prefer 60 seconds).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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