Search code examples
nginxmonit

reload nginx with monit


I'm looking to reload, not restart, nginx with monit. The docs say that valid service methods are start, stop and restart but not reload.

Does anyone have a workaround for how to reload nginx rather than restart it?

Edit - I should have pointed out that I still require the ability to restart nginx but I also need, under certain conditions, to reload nginx only.

An example might be that if nginx goes down it needs to be restarted but if it has an uptime > 3 days (for example) it should be reloaded.

I'm trying to achieve this: https://mmonit.com/monit/documentation/monit.html#UPTIME-TESTING

...but with nginx reloading, not restarting.

Thanks.


Solution

  • I solved this issue using the exec command when my conditions are met. For example:

    check system localhost
      if memory > 95%
      for 4 cycles
      then exec "/etc/init.d/nginx reload"
    

    I've found that nginx memory issues can be resolved in the short term by reloading rather than restarting.