Skip to content

Commit 87e2b92

Browse files
committed
Make sure php-fpm dummy config are present before restarting web backend
1 parent 4fea282 commit 87e2b92

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

bin/v-restart-web-backend

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@ PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
1717
send_email_report() {
1818
email=$(grep CONTACT $HESTIA/data/users/admin/user.conf)
1919
email=$(echo "$email" | cut -f 2 -d "'")
20-
tmpfile=$(mktemp)
2120
subj="$(hostname): $WEB_BACKEND restart failed"
22-
service $WEB_BACKEND configtest >> $tmpfile 2>&1
23-
service $WEB_BACKEND restart >> $tmpfile 2>&1
2421
cat $tmpfile |$SENDMAIL -s "$subj" $email
25-
rm -f $tmpfile
22+
[[ -f "$tmpfile" ]] && rm -f $tmpfile
2623
}
2724

2825

@@ -46,20 +43,24 @@ if [ -z "$WEB_BACKEND" ] || [ "$WEB_BACKEND" = 'remote' ]; then
4643
exit
4744
fi
4845

49-
# Restart system
50-
php_fpm=$(ls /etc/init.d/php*-fpm* 2>/dev/null |cut -f 4 -d /)
51-
for back in $php_fpm
52-
do
53-
if [ -z "$php_fpm" ]; then
54-
$BIN/v-restart-service $WEB_BACKEND > /dev/null 2>&1
55-
else
56-
$BIN/v-restart-service $back > /dev/null 2>&1
46+
tmpfile=$(mktemp)
47+
for php_folder in /etc/php/*; do
48+
[ ! -d "${php_folder}/fpm/pool.d/" ] && continue
49+
50+
v_php="$(basename $php_folder)"
51+
v_phpfpm="php${v_php}-fpm"
52+
53+
if [ ! -f "/etc/php/${v_php}/fpm/pool.d/dummy.conf" ]; then
54+
cp -f "$HESTIA_INSTALL_DIR/php-fpm/dummy.conf" "/etc/php/${v_php}/fpm/pool.d/"
55+
sed -i "s/9999/99${v_php//.}/g" "/etc/php/${v_php}/fpm/pool.d/dummy.conf"
56+
fi
57+
58+
$BIN/v-restart-service "$v_phpfpm" >> $tmpfile 2>&1
59+
if [ $? -ne 0 ]; then
60+
send_email_report
61+
check_result $E_RESTART "$v_phpfpm restart failed"
5762
fi
5863
done
59-
if [ $? -ne 0 ]; then
60-
send_email_report
61-
check_result $E_RESTART "$WEB_BACKEND restart failed"
62-
fi
6364

6465
# Update restart queue
6566
if [ -e "$HESTIA/data/queue/restart.pipe" ]; then
@@ -71,4 +72,5 @@ fi
7172
# Hestia #
7273
#----------------------------------------------------------#
7374

75+
[[ -f "$tmpfile" ]] && rm -f $tmpfile
7476
exit

0 commit comments

Comments
 (0)