Skip to content

Commit 694806a

Browse files
committed
Fix restarting php-fpm service (both single and multiphp)
1 parent 0dcdbd5 commit 694806a

File tree

2 files changed

+41
-34
lines changed

2 files changed

+41
-34
lines changed

bin/v-change-sys-service-config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ if [ "$update" = 'yes' ] && [ "$restart" != 'no' ]; then
9999
fi
100100

101101
if [ "$service" = 'php' ]; then
102-
if [ "$WEB_SYSTEM" = "nginx" ]; then
103-
service=$(ls /etc/init.d/php*fpm* |cut -f 4 -d / |sed -n 1p)
104-
else
102+
if [ "$(multiphp_count)" -gt 0 ]; then
103+
service="php-fpm"
104+
elif [ "$WEB_SYSTEM" = 'apache2' ]; then
105105
service="$WEB_SYSTEM"
106106
fi
107107
fi

bin/v-restart-service

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,41 +29,48 @@ is_format_valid 'service' 'restart'
2929
# Action #
3030
#----------------------------------------------------------#
3131

32-
if [ "$service" = "iptables" ]; then
33-
# Run the restart rules for iptables firewall
34-
$BIN/v-stop-firewall
35-
$BIN/v-update-firewall
36-
elif [ -z "$restart" -o "$restart" = "no" ] && [ \
37-
"$service" = "nginx" -o \
38-
"$service" = "apache2" -o \
39-
"$service" = "exim4" -o \
40-
"$service" = "dovecot" -o \
41-
"$service" = "bind9" -o \
42-
"$service" = "named" -o \
43-
"$service" = "vsftpd" -o \
44-
"$service" = "php5.6-fpm" -o \
45-
"$service" = "php7.0-fpm" -o \
46-
"$service" = "php7.1-fpm" -o \
47-
"$service" = "php7.2-fpm" -o \
48-
"$service" = "php7.3-fpm" -o \
49-
"$service" = "proftpd" -o \
50-
"$service" = "ssh" -o \
51-
"$service" = "fail2ban" ]; then
52-
systemctl reload-or-restart $service > /dev/null 2>&1
32+
if [ "$service" = "php-fpm" ];then
33+
for php_ver in $(multiphp_versions); do
34+
service_list="${service_list} php${php_ver}-fpm"
35+
done
5336
else
54-
systemctl reset-failed $service > /dev/null 2>&1
55-
systemctl restart $service > /dev/null 2>&1
37+
service_list="$service"
5638
fi
5739

58-
#----------------------------------------------------------#
59-
# Hestia #
60-
#----------------------------------------------------------#
40+
for service in $service_list; do
6141

62-
# Check the result of the service restart and report whether it failed.
63-
if [ $? -ne 0 ]; then
64-
check_result $E_RESTART "ERROR: Restart of $service failed."
65-
log_history "Restart of $service failed."
66-
fi
42+
if [ "$service" = "iptables" ]; then
43+
# Run the restart rules for iptables firewall
44+
$BIN/v-stop-firewall
45+
$BIN/v-update-firewall
46+
elif [ -z "$restart" -o "$restart" = "no" ] && [ \
47+
"$service" = "nginx" -o \
48+
"$service" = "apache2" -o \
49+
"$service" = "exim4" -o \
50+
"$service" = "dovecot" -o \
51+
"$service" = "bind9" -o \
52+
"$service" = "named" -o \
53+
"$service" = "vsftpd" -o \
54+
"$service" = "php5.6-fpm" -o \
55+
"$service" = "php7.0-fpm" -o \
56+
"$service" = "php7.1-fpm" -o \
57+
"$service" = "php7.2-fpm" -o \
58+
"$service" = "php7.3-fpm" -o \
59+
"$service" = "proftpd" -o \
60+
"$service" = "ssh" -o \
61+
"$service" = "fail2ban" ]; then
62+
systemctl reload-or-restart $service > /dev/null 2>&1
63+
else
64+
systemctl reset-failed $service > /dev/null 2>&1
65+
systemctl restart $service > /dev/null 2>&1
66+
fi
67+
68+
# Check the result of the service restart and report whether it failed.
69+
if [ $? -ne 0 ]; then
70+
check_result $E_RESTART "ERROR: Restart of $service failed."
71+
log_history "Restart of $service failed."
72+
fi
73+
done
6774

6875
# Logging
6976
log_event "$OK" "$ARGUMENTS"

0 commit comments

Comments
 (0)