Automatically restart services if down?

Will hestiacp automatically restart services after they go down?
On vestacp, from time to time mysql is down but didnt restart itself. I need to install monit to make it autorestart.

So, the question is will hestiacp autorestart service if one of them is down?

You supposed to check why it stopped.
Better dont make any scripts for that to auto-restart. Instead you should rectify the issue, before it spoil your server.

1 Like

Nothing is wrong.
For example I can make fresh install vestacp down. Just send too much traffic. And it will get down.

But after I install monit it will gets auto restarted.

Vestacp have monit installed, but we neeed to enable it manually. They have monit config for each of the services, for example:

http://c.vestacp.com/rhel/7/monit/vesta-nginx.conf #nginx
http://c.vestacp.com/rhel/7/monit/httpd.conf #Apache
http://c.vestacp.com/rhel/7/monit/mysql.conf #MySQL

There is no such feature in hestiacp?

So, your question supposed to be ā€˜Get notified while the service stoppedā€™.
Should not be as ā€˜Feature to auto-restart of mysql while it down with reasonsā€™.

To get alerted for mysql service, currently no feature yet on hestia & many branded leading panels also will not let us to have this feature by default [alerting only]. The reason is the alert feature is not guaranteed.
Let say, if server down, email service down etc.,

I set a 3rd party service, which will just keep monitoring my essential ports & alert me if it down.

in your case, you have to find what is that break point, which is stopping your mysql.
Also set some scripts to ALERT you only. Dont auto-restart. As SysAdmin people, they knows well why im saying this.

Installing a monitoring software it self is never a bad idea

Personally I would suggest a Nagios and host on a 2nd location so they will inform you if a server goes down. And inform you when your server is down.

There is no need for monit or other additional programs to restart failed services, systemd has this functionality built-in see manual

Also mysql service is configured to restart itsef ā€œon-abortā€ ( cat /etc/systemd/system/mysqld.service ) so any workarounds you had to configure previously are probably not needed anymore

# Restart crashed server only, on-failure would also restart, for example, when
# my.cnf contains unknown option
Restart=on-abort
RestartSec=5s

But If you still want to change the restart condition to ā€œon-failureā€ or ā€œalwaysā€ , extend the unit file :

mkdir -p /etc/systemd/system/mariadb.service.d
echo -e "[Service]\nRestart=on-failure" > /etc/systemd/system/mariadb.service.d/my.conf
systemctl daemon-reload
2 Likes