How to automatically monitor and power cycle a droplet when it's down?
I’ve been running into issues where my website becomes non-responsive or very slow to load. Currently I’m using an external uptime monitor to notify me when this happens and I manually go into the DO control panel to do a Power Cycle, which fixes the problem. I’m not sure WHY this keeps happening but this fix seems to be working fine. The script I’m running does not have any MySQL connections, it is purely based on PHP.
Looking over the graphs in the DO control panel I notice no significant changes in CPU, bandwidth or disk spikes. The most I’ve ever been at was around 45% CPU for a short period of time. I don’t know what’s causing it and the graphs seem to offer me no clues, since even those spikes don’t correlate well to the downtime.
The only solution I can think of is to run a cheap $5 droplet which would run a cron say every 30 seconds, to check for downtime, and then execute some PHP code to powercycle the droplet automatically. Problem is I have no idea how to do this! Could anyone provide some guidance?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.