![]() It should automatically restart if the process goes down, with no additional config, but if you want to restart based on resource usage, you'll have to specify that yourself with a few if statements: You'll need to pass Monit a command to start and stop your process. Start program = "/etc/init.d/nginx start" Usually, this is done with the processes PID file (often found in /var/run/) which stores the current PID of the running instance of that process, since the PID will change whenever the process restarts.Ĭheck process nginx with pidfile /var/run/nginx.pid Monit can then be configured to monitor individual processes. There's a few more configuration options for the web interface, but this is good for now. ![]() We'll want to lock it down to an authorized IP address andĬhange this password, of course. This is fine, but it's entirely open by default with a default password. Monit's web interface is configured to run on port 2812. If MySQL starts using too many resources, it can be restarted automatically, though you'll be warned by email first. If it goes down, it can start it again using the start program = config. Monit is configured to monitor the running MySQL process. If 3 restarts within 5 cycles then timeout If totalmem > 600 MB for 5 cycles then restart If totalmem > 400 MB for 5 cycles then alert Stop program = "/usr/sbin/service mysql stop" with timeout 60 seconds Start program = "/usr/sbin/service mysql start" with timeout 60 seconds Here's the default config for MySQL as an example: Monit defines its behavior entirely through config files. This includes relaunching crashed processes, and restarting processes using too many resources. It keeps a log of resource usage, and can take action if an error occurs. ![]() Essentially, Monit will check in on a given process every two minutes (by default) to see how it's doing.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |