net-mgmt/unifi5: Clean up child processes

Unifi starts up its own mongodb child process automatically. It does
this regardless of any existing mongodb process running on the system.
If you attempt to restart unifi without stopping its mongodb process it
will attempt to start mongodb processes for eternity, filling your logs.
This situation is regularly encountered by users updating to the newest
release.

There is no workaround but to signal any remaining processes owned by
the unifi user at shutdown. The included change takes note of any child
PIDs before starting shutdown and signals them after the unifi process
has been stopped successfully.

Reported by:	dvl
This commit is contained in:
Mark Felder 2017-02-08 21:49:19 +00:00
parent d8a215acb1
commit 9db73373bf
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=433676
2 changed files with 20 additions and 1 deletions

View file

@ -3,7 +3,7 @@
PORTNAME= unifi5
PORTVERSION= 5.4.11
PORTREVISION= 0
PORTREVISION= 1
CATEGORIES= net-mgmt java
MASTER_SITES= https://www.ubnt.com/downloads/unifi/${PORTVERSION}-${UNIFI_TAG}/ \
LOCAL/feld/${PORTNAME}-${PORTVERSION}/

View file

@ -30,6 +30,8 @@ procname=%%JAVA%%
command="/usr/sbin/daemon"
command_args="-f -p ${pidfile} %%JAVA%% ${unifi_javaflags} -jar lib/ace.jar start"
start_precmd=start_precmd
stop_precmd=stop_precmd
stop_postcmd=stop_postcmd
start_precmd()
{
@ -38,4 +40,21 @@ start_precmd()
fi
}
stop_precmd()
{
if [ -r ${pidfile} ]; then
_UNIFIPID=$(check_pidfile ${pidfile} ${procname})
export _UNIFI_CHILDREN=$(pgrep -P ${_UNIFIPID})
fi
}
stop_postcmd()
{
if ! [ -z ${_UNIFI_CHILDREN} ]; then
echo "Cleaning up leftover child processes."
kill $sig_stop ${_UNIFI_CHILDREN}
wait_for_pids ${_UNIFI_CHILDREN}
fi
}
run_rc_command "$1"