Page 1 of 1

Vesta service is not auto restarting ?

Posted: Wed Oct 30, 2019 2:00 pm
by MrCraac
Hi,

I manage many vesta servers and on a regular basis the web interface is not available due to a service issue.
Service status is active, but excited:

Code: Select all

vesta.service - SYSV: Run vesta web server
   Loaded: loaded (/etc/rc.d/init.d/vesta; bad; vendor preset: disabled)
   Active: active (exited) since Tue 2019-04-16 01:03:22 CEST; 6 months 14 days ago
     Docs: man:systemd-sysv-generator(8)
in 99.99% of those case, just restarting the service is enough to make it works.
Looking into the service configuration below:

Code: Select all

[root@app ~]# systemctl cat vesta.service
# /run/systemd/generator.late/vesta.service
# Automatically generated by systemd-sysv-generator

[Unit]
Documentation=man:systemd-sysv-generator(8)
SourcePath=/etc/rc.d/init.d/vesta
Description=SYSV: Run vesta web server
Before=runlevel2.target
Before=runlevel3.target
Before=runlevel4.target
Before=runlevel5.target
Before=shutdown.target
After=network-online.target
After=network.service
Conflicts=shutdown.target

[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
ExecStart=/etc/rc.d/init.d/vesta start
ExecStop=/etc/rc.d/init.d/vesta stop
ExecReload=/etc/rc.d/init.d/vesta reload
I have found that the restart param is set to =no. Which is not convenient at all in my opinion (I have calls on vesta API that can't work due to this)
I am thinking of editing this , using the always option or perhaps using the watchdog param, but maybe this is set on purpose to avoid issues.
If a dev from Vesta reads me (or someone well informed), Is there a specific reason for setting this to not restart ?
Is it safe to change it to "always" ?

Thank you for reading me.

Re: Vesta service is not auto restarting ?

Posted: Thu Oct 31, 2019 11:46 am
by MrCraac
Hi,

I did some test trying to use the always option for restart param and also the watchdog. None have worked. Maybe I did not did it properly, as I am not use to play with services configuration.

So my last solution will be to write and deploy to a watchdog script monitoring the panel URL and restarting the service while down.

Re: Vesta service is not auto restarting ?

Posted: Thu Oct 31, 2019 12:33 pm
by grayfolk
MrCraac wrote: Thu Oct 31, 2019 11:46 am Hi,

I did some test trying to use the always option for restart param and also the watchdog. None have worked. Maybe I did not did it properly, as I am not use to play with services configuration.

So my last solution will be to write and deploy to a watchdog script monitoring the panel URL and restarting the service while down.
Did you make systemctl daemon-reload after add always option?

Re: Vesta service is not auto restarting ?

Posted: Thu Oct 31, 2019 2:39 pm
by MrCraac
Yes I did , it seems that the status "available (excited)" may not be seen as a failure.
From the examples I found, a well known service using this state is iptables.
Iptables just runs a process at start, when done it is not running anymore. So the service shown available because iptables service is available and excited because there is no more process running (and not need to run any).

But, this should not be the behavior of the vesta service, as it needs nginx process to run properly.

Code: Select all

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
● vesta.service - SYSV: Run vesta web server
   Loaded: loaded (/etc/rc.d/init.d/vesta; bad; vendor preset: disabled)
   Active: active (exited) since Sat 2019-08-17 05:20:18 CEST; 2 months 14 days ago
     Docs: man:systemd-sysv-generator(8)
vs

Code: Select all

vesta.service - SYSV: Run vesta web server
   Loaded: loaded (/etc/rc.d/init.d/vesta; bad; vendor preset: disabled)
   Active: active (running) since Thu 2019-10-24 12:09:50 CEST; 1 weeks 0 days ago
     Docs: man:systemd-sysv-generator(8)
  Process: 19445 ExecStop=/etc/rc.d/init.d/vesta stop (code=exited, status=0/SUCCESS)
  Process: 19455 ExecStart=/etc/rc.d/init.d/vesta start (code=exited, status=0/SUCCESS)
    Tasks: 5
   Memory: 17.1M
   CGroup: /system.slice/vesta.service
           ├─19462 nginx: master process /usr/local/vesta/nginx/sbin/vesta-nginx
           ├─19465 nginx: worker process
           ├─19468 php-fpm: master process (/usr/local/vesta/php/etc/php-fpm.conf)
           ├─19469 php-fpm: pool www
           └─19470 php-fpm: pool www

Re: Vesta service is not auto restarting ?

Posted: Thu Nov 14, 2019 4:15 pm
by MrCraac
Ok so I ended up by creating a watcher for the service.

Maybe not the most proper way , but as it works I will use it.
However, I am still confused that vesta can't at least warn when its own apache or nginx server has failed.

Here is my little addition , I sampled a vesta cli script , then called it from the cron.
It adds a log entry for the user when triggered.
I have also used another script that send slack notifications.

Code: Select all

#!/bin/bash
# watch vesta process status 
# options: NONE
#
# The function restart vesta if nginx or php fails.


#----------------------------------------------------------#
#                    Variable&Function                     #
#----------------------------------------------------------#

# Argument definition
user=$1


# Includes

source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf

#----------------------------------------------------------#
#                    Verifications                         #
#----------------------------------------------------------#

check_args '1' "$#" 'USER'
is_format_valid 'user'


#----------------------------------------------------------#
#                       Action                             #
#----------------------------------------------------------#

if (( $(ps -ef |grep -v grep |grep vesta-nginx |wc -l) < 1 ))
then
        service vesta restart
        if [ $? -eq 0 ]
        then
            log_history "Vesta service has been restarted"
            /usr/local/bin/slackpost.sh "good" "Vesta restart success"
        else
            log_history "Vesta restart failed"
            /usr/local/bin/slackpost.sh "danger" "Vesta restart failed"
        fi

else
if (( $(ps -ef |grep -v grep |grep /usr/local/vesta/php/etc/php-fpm.conf |wc -l) < 1 ))
then
        service vesta restart
        if [ $? -eq 0 ]
        then
            log_history "Vesta service has been restarted"
            /usr/local/bin/slackpost.sh "good" "Vesta restart success"
        else
            log_history "Vesta restart failed"
            /usr/local/bin/slackpost.sh "danger" "Vesta restart failed"
        fi

fi
fi
Maybe this will help someone :)
Of course if you have any suggestions for improvement, I will be happy to hear them!