Self-healing and outside checks
How the server restarts a service that hangs, how the panel restarts itself, how the servers of a cluster and a standby pair watch each other, and how to watch a single server from outside.
A crashed service is easy to spot: it stops, and the server starts it again within seconds. A service that hangs is harder: it still runs, so nothing restarts it, yet websites, the panel or email stop answering. Hfog Panel looks for both, fixes what it can and tells the administrators what it could not.
What restarts by itself
| What | How it is watched | What happens |
|---|---|---|
| A crashed service (Nginx, Apache, PHP, MariaDB, Dovecot, BIND, FTP …) | systemd | Started again after 5 seconds, at most 10 times in 5 minutes. |
| A hung web stack, mail or DNS service | the watchdog, every minute (below) | Restarted when it did not answer twice in a row. |
| The panel itself (hfog-api) | systemd's watchdog | Restarted when it stops answering for 2 minutes. |
The watchdog
Every minute the watchdog asks each running service the way a visitor would, and gives it 30 seconds to answer:
| Service | Question |
|---|---|
| Nginx | a request on this server's own address |
| PHP | a tiny page run by PHP, which also asks the database |
| Apache or OpenLiteSpeed | the same page (Apache) or any page (OpenLiteSpeed), through Nginx |
| MariaDB | a one-line query |
| Postfix, Dovecot | their greeting on ports 25 and 143 (when the server hosts email) |
| BIND | a DNS query (when the server hosts DNS) |
The official edition, which runs HQ alone, has no hosting: there only Nginx, email and DNS are asked.
The probe page holds no password and answers only requests from the server itself. A service that refuses a request (for example while it starts) does not count as hung; only one that takes the request and then says nothing does.
When it restarts a service
- Only after it did not answer twice in a row (two runs, a minute apart).
- Not when it was started less than 2 minutes ago.
- At most once every 15 minutes, and at most 3 times in 6 hours for the same service. After that it is left as it is and the administrators are told.
- Never while an update, the installer or a package install runs, or while you paused it.
After a restart the watchdog asks again for half a minute. You get a notification for every restart (Service restarted by the watchdog) and an urgent alert, Service not answering, when the restart did not help or the service was restarted too often. Both are in the Activity log too, and they go to the channels you chose under Notifications.
Everything the watchdog finds and does is written to /var/log/hostfog-watchdog.log:
tail -n 50 /var/log/hostfog-watchdog.log
systemctl list-timers hostfog-watchdog.timer # when it runs next
Pause it while you work on the server
When you stop or test services by hand, pause the watchdog so that it does not restart them in the middle of your work (at most 1,440 minutes; it goes on by itself afterwards):
sudo /usr/local/hostfog/bin/hfog-agentd watchdog-pause 60 # no restarts for 60 minutes
sudo /usr/local/hostfog/bin/hfog-agentd watchdog-pause 0 # go on now
The panel
The panel program sends systemd a sign of life every 30 seconds, but only after it has answered a request on its own
socket and its database has answered a query. When no sign comes for 2 minutes, systemd restarts it and writes what
every part of the program was doing to its journal (journalctl -u hostfog-api).
Outside checks
A server cannot report that it is gone. Each server that has another one next to it is watched from there:
| Set-up | Who watches whom | Alert |
|---|---|---|
| Servers of a cluster | The main panel reads every joined server every 5 minutes. | Server not answering, on the main panel, after the minutes set under Fleet (15 by default). |
| Each joined server notes when the main panel was last in touch. | Main server not in touch, on the joined server, after the same minutes. | |
| Standby & failover | The standby checks its primary every 20 seconds. | Primary server unreachable and Standby took over; also when an automatic takeover failed. |
Joined servers need email or another channel of their own for Main server not in touch: set up their administrators' notifications on each server.
A single server
A server with nothing next to it needs a check from somewhere else. Use any one of these:
- Another Hfog Panel server: in its Control Panel, add an Uptime monitor for
this server's panel address (
https://srv.yourdomain.com:8443/healthz) and one for an important website. Each check runs from that server, so it still works when this one is down. - An external uptime service: add a check of the same addresses every 1 to 5 minutes, with your email or phone as its contact.
Watch at least one website as well as the panel: the panel can answer while the websites do not.