mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-10-20 04:03:51 +02:00
Make service stop/restart reliably recycle the daemonized php-fpm
The bundled php-fpm daemonizes out of systemd's cgroup, so a soft stop left masters (and their stale OPcache) alive after php.ini changes. Rewrite stop() to hard-kill by UID (escalating to SIGKILL, always returns 0), split boot() from the foreground start() so a manual `service restart` no longer holds the console, and guard the kill pipeline with xargs -r.
This commit is contained in:
+18
-8
@@ -8,12 +8,9 @@ if [ "$USER" != "root" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
start() {
|
||||
pids=$(pgrep -u xc_vm nginx | wc -l)
|
||||
if [ $pids != 0 ]; then
|
||||
echo 'XC_VM is already running'
|
||||
return 1
|
||||
fi
|
||||
# Launch every XC_VM service. Does NOT block — shared by start (foreground) and
|
||||
# restart (returns to the shell).
|
||||
boot() {
|
||||
echo 'Starting XC_VM...'
|
||||
sudo chown -R xc_vm:xc_vm /sys/class/net
|
||||
sudo chown -R xc_vm:xc_vm /home/xc_vm/content/streams
|
||||
@@ -29,6 +26,18 @@ start() {
|
||||
sudo -u xc_vm $SCRIPT/bin/php/bin/php $SCRIPT/console.php watchdog >/dev/null 2>/dev/null &
|
||||
sudo -u xc_vm $SCRIPT/bin/php/bin/php $SCRIPT/console.php queue >/dev/null 2>/dev/null &
|
||||
sudo -u xc_vm $SCRIPT/bin/php/bin/php $SCRIPT/console.php cache_handler >/dev/null 2>/dev/null &
|
||||
}
|
||||
|
||||
# Foreground entry for systemd (Type=simple): boot, then stay alive so systemd
|
||||
# keeps tracking the unit. Holds the terminal BY DESIGN — for a manual,
|
||||
# non-blocking restart use `restart` (or `systemctl restart|reload xc_vm`).
|
||||
start() {
|
||||
pids=$(pgrep -u xc_vm nginx | wc -l)
|
||||
if [ $pids != 0 ]; then
|
||||
echo 'XC_VM is already running'
|
||||
return 1
|
||||
fi
|
||||
boot
|
||||
echo 'Running in foreground...'
|
||||
sleep infinity
|
||||
}
|
||||
@@ -52,9 +61,10 @@ stop() {
|
||||
|
||||
restart() {
|
||||
# Hard-recycle every xc_vm process EXCEPT ffmpeg (keeps active transcodes/
|
||||
# streams running) then start fresh — this is what reliably flushes OPcache.
|
||||
# streams running) then boot fresh — reliably flushes OPcache. Returns to the
|
||||
# shell; does NOT hold the console (boot, not the foreground start).
|
||||
ps -U xc_vm | egrep -v "ffmpeg|PID" | awk '{print $1}' | xargs -r kill -9
|
||||
start
|
||||
boot
|
||||
}
|
||||
|
||||
reload() {
|
||||
|
||||
Reference in New Issue
Block a user