Compare commits

..

No commits in common. "488e278b041de05525bbde2957be90dc75bd654d" and "592a9d8688396ef414b79a38695fd88763312e54" have entirely different histories.

View file

@ -34,18 +34,52 @@ on_interrupt() {
}
start_messenger() {
nohup php8.1 bin/console messenger:consume 2>/dev/null >/dev/null &
started=0
pid=
if [ -f "$pid_file" ]; then
pid="$(cat "$pid_file")"
fi
if [ -n "$pid" ]; then
if [ -d "/proc/$pid" ]; then
log -t -l warning "Already running"
started=1
fi
fi
if [ "$started" -eq 0 ]; then
nohup php8.1 bin/console messenger:consume 2>/dev/null >/dev/null &
echo -n $! > "$pid_file"
log -t -l notice "Started"
fi
}
stop_messenger() {
php8.1 bin/console messenger:stop-workers
log -t -l notice "Stopped"
pid=
if [ -f "$pid_file" ]; then
pid="$(cat "$pid_file")"
fi
if [ -n "$pid" ]; then
if [ ! -d "/proc/$pid" ]; then
log -t -l warning "Not started"
else
kill -9 "$pid"
log -t -l notice "Stopped"
fi
rm "$pid_file"
else
log -t -l warning "Not started"
fi
}
main() {
cd "$(dirname "0")"
ACTION=
pid_file=var/messenger.pid
while getopts "l:ha:" option; do
case "${option}" in
@ -63,10 +97,10 @@ main() {
elif [ "$ACTION" = "restart" ]; then
stop_messenger
start_messenger
else
log -l error "Action no defined."
fi
# log [-t] [-l debug|info|notice|warning|error] message
exit 0
}