Compare commits
2 commits
592a9d8688
...
488e278b04
Author | SHA1 | Date | |
---|---|---|---|
488e278b04 | |||
28f8e5c583 |
|
@ -34,52 +34,18 @@ on_interrupt() {
|
|||
}
|
||||
|
||||
start_messenger() {
|
||||
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() {
|
||||
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"
|
||||
php8.1 bin/console messenger:stop-workers
|
||||
log -t -l notice "Stopped"
|
||||
fi
|
||||
|
||||
rm "$pid_file"
|
||||
else
|
||||
log -t -l warning "Not started"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
cd "$(dirname "0")"
|
||||
|
||||
pid_file=var/messenger.pid
|
||||
ACTION=
|
||||
|
||||
while getopts "l:ha:" option; do
|
||||
case "${option}" in
|
||||
|
@ -97,10 +63,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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue