diff options
Diffstat (limited to 'sysutils/cbsd/files')
-rw-r--r-- | sysutils/cbsd/files/cbsd-statsd-bhyve.in | 43 | ||||
-rw-r--r-- | sysutils/cbsd/files/cbsd-statsd-hoster.in | 32 | ||||
-rw-r--r-- | sysutils/cbsd/files/cbsd-statsd-jail.in | 39 |
3 files changed, 108 insertions, 6 deletions
diff --git a/sysutils/cbsd/files/cbsd-statsd-bhyve.in b/sysutils/cbsd/files/cbsd-statsd-bhyve.in index be56087326c1..14de0265d510 100644 --- a/sysutils/cbsd/files/cbsd-statsd-bhyve.in +++ b/sysutils/cbsd/files/cbsd-statsd-bhyve.in @@ -20,14 +20,18 @@ export workdir="${cbsd_workdir}" globalconf=${cbsd_globalconf:-"%%PREFIX%%/cbsd/cbsd.conf"} start_cmd=${name}_start +stop_cmd=${name}_stop restart_cmd=${name}_restart extra_commands="restart" command="%%PREFIX%%/cbsd/tools/racct-bhyve-statsd" -pidfile="/var/run/$name.pid" -command_args="&" +pidfile="${cbsd_workdir}/var/run/${name}.pid" +daemon_pidfile="${cbsd_workdir}/var/run/${name}-daemon.pid" +daemon_logdir="/var/log/${name}" +workdir_normalize=$( echo ${cbsd_workdir} | /usr/bin/tr "/" "_" ) +daemon_logfile="${daemon_logdir}/cbsd-statsd-bhyve${workdir_normalize}.log" -pidfile=/var/run/racct-bhyve-statsd.pid +command_args="&" if [ ! -f ${globalconf} ]; then echo "cbsd: no such ${globalconf}"; @@ -42,6 +46,34 @@ fi . ${globalconf} . ${subrdir}/nc.subr +cbsd_statsd_bhyve_stop() +{ + local _pids + + if [ -f "${daemon_pidfile}" ]; then + _pids=$( pgrep -F ${daemon_pidfile} 2>&1 ) + _err=$? + /bin/rm -f ${daemon_pidfile} + if [ ${_err} -eq 0 ]; then + kill -9 ${_pids} + else + echo "pgrep: ${_pids}" + fi + fi + if [ -f "${pidfile}" ]; then + _pids=$( pgrep -F ${pidfile} 2>&1 ) + _err=$? + /bin/rm -f ${pidfile} + if [ ${_err} -eq 0 ]; then + kill -9 ${_pids} + else + echo "pgrep: ${_pids}" + fi + fi + + return 0 +} + cbsd_statsd_bhyve_start() { local args= racct_enabled= @@ -84,7 +116,10 @@ cbsd_statsd_bhyve_start() ;; esac - exec env workdir=${cbsd_workdir} %%PREFIX%%/cbsd/tools/racct-bhyve-statsd ${args} + [ ! -d ${daemon_logdir} ] && mkdir -p ${daemon_logdir} + touch ${daemon_logfile} + + /usr/sbin/daemon -f -R5 -P ${daemon_pidfile} -o ${daemon_logfile} /usr/bin/env workdir=${cbsd_workdir} ${command} ${args} } cbsd_statsd_bhyve_restart() diff --git a/sysutils/cbsd/files/cbsd-statsd-hoster.in b/sysutils/cbsd/files/cbsd-statsd-hoster.in index 730898d63964..a8aa94a8d3c0 100644 --- a/sysutils/cbsd/files/cbsd-statsd-hoster.in +++ b/sysutils/cbsd/files/cbsd-statsd-hoster.in @@ -20,6 +20,7 @@ export workdir="${cbsd_workdir}" globalconf=${cbsd_globalconf:-"%%PREFIX%%/cbsd/cbsd.conf"} start_cmd=${name}_start +stop_cmd=${name}_stop restart_cmd=${name}_restart extra_commands="restart" @@ -46,6 +47,35 @@ fi . ${globalconf} . ${subrdir}/nc.subr + +cbsd_statsd_hoster_stop() +{ + local _pids + + if [ -f "${daemon_pidfile}" ]; then + _pids=$( pgrep -F ${daemon_pidfile} 2>&1 ) + _err=$? + /bin/rm -f ${daemon_pidfile} + if [ ${_err} -eq 0 ]; then + kill -9 ${_pids} + else + echo "pgrep: ${_pids}" + fi + fi + if [ -f "${pidfile}" ]; then + _pids=$( pgrep -F ${pidfile} 2>&1 ) + _err=$? + /bin/rm -f ${pidfile} + if [ ${_err} -eq 0 ]; then + kill -9 ${_pids} + else + echo "pgrep: ${_pids}" + fi + fi + + return 0 +} + cbsd_statsd_hoster_start() { local args= racct_enabled= @@ -91,7 +121,7 @@ cbsd_statsd_hoster_start() [ ! -d ${daemon_logdir} ] && mkdir -p ${daemon_logdir} touch ${daemon_logfile} - /usr/sbin/daemon -f -R5 -p ${pidfile} -P ${daemon_pidfile} -o ${daemon_logfile} /usr/bin/env workdir=${cbsd_workdir} ${command} ${args} + /usr/sbin/daemon -f -R5 -P ${daemon_pidfile} -o ${daemon_logfile} /usr/bin/env workdir=${cbsd_workdir} ${command} ${args} } cbsd_statsd_hoster_restart() diff --git a/sysutils/cbsd/files/cbsd-statsd-jail.in b/sysutils/cbsd/files/cbsd-statsd-jail.in index d109f76ebbbd..6c529ce1c0b9 100644 --- a/sysutils/cbsd/files/cbsd-statsd-jail.in +++ b/sysutils/cbsd/files/cbsd-statsd-jail.in @@ -20,11 +20,17 @@ export workdir="${cbsd_workdir}" globalconf=${cbsd_globalconf:-"%%PREFIX%%/cbsd/cbsd.conf"} start_cmd=${name}_start +stop_cmd=${name}_stop restart_cmd=${name}_restart extra_commands="restart" command="%%PREFIX%%/cbsd/tools/racct-jail-statsd" pidfile="${cbsd_workdir}/var/run/${name}.pid" +daemon_pidfile="${cbsd_workdir}/var/run/${name}-daemon.pid" +daemon_logdir="/var/log/${name}" +workdir_normalize=$( echo ${cbsd_workdir} | /usr/bin/tr "/" "_" ) +daemon_logfile="${daemon_logdir}/cbsd-statsd-jail${workdir_normalize}.log" + command_args="&" if [ ! -f ${globalconf} ]; then @@ -40,6 +46,34 @@ fi . ${globalconf} . ${subrdir}/nc.subr +cbsd_statsd_jail_stop() +{ + local _pids + + if [ -f "${daemon_pidfile}" ]; then + _pids=$( pgrep -F ${daemon_pidfile} 2>&1 ) + _err=$? + /bin/rm -f ${daemon_pidfile} + if [ ${_err} -eq 0 ]; then + kill -9 ${_pids} + else + echo "pgrep: ${_pids}" + fi + fi + if [ -f "${pidfile}" ]; then + _pids=$( pgrep -F ${pidfile} 2>&1 ) + _err=$? + /bin/rm -f ${pidfile} + if [ ${_err} -eq 0 ]; then + kill -9 ${_pids} + else + echo "pgrep: ${_pids}" + fi + fi + + return 0 +} + cbsd_statsd_jail_start() { local args= racct_enabled= pool_name= prometheus_listen4= prometheus_listen6= prometheus_port= @@ -88,7 +122,10 @@ cbsd_statsd_jail_start() ;; esac - exec env workdir=${cbsd_workdir} %%PREFIX%%/cbsd/tools/racct-jail-statsd ${args} + [ ! -d ${daemon_logdir} ] && mkdir -p ${daemon_logdir} + touch ${daemon_logfile} + + /usr/sbin/daemon -f -R5 -P ${daemon_pidfile} -o ${daemon_logfile} /usr/bin/env workdir=${cbsd_workdir} ${command} ${args} } cbsd_statsd_jail_restart() |