pidfiles are evil

This commit is contained in:
Jack L. Frost 2014-07-03 11:05:52 +04:00
parent c9168818d4
commit 4bf86dc02f
12 changed files with 38 additions and 28 deletions

View File

@ -2,7 +2,8 @@
unset reload
service_command='/usr/bin/cjdroute'
service_command='/usr/local/sbin/cjdroute-start'
service_respawn=true
cjdroute_config='/etc/cjdroute.conf'
cjdroute_admin_port='11234'
@ -16,10 +17,6 @@ cjdroute.check_tun_module() {
}
}
get_pid() {
lsof -i :"$cjdroute_admin_port" | tail -1 | cut -d ' ' -f 2
}
start() {
cjdroute.check_tun_module || { return 1; }
@ -28,7 +25,16 @@ start() {
return 1
}
"$service_command" < "${cjdroute_config}" &>"$service_logfile" && {
watchman.msg "${service_name} started"
watchman.start
}
stop() {
[[ "$service_respawn" == 'true' ]] && { watchman.stop; } # stopping the watchdog
# Stopping the actual s-o-b daemon that won't die properly.
cjdroute_control_pid=`lsof -i :"$cjdroute_admin_port" | tail -1 | cut -d ' ' -f 2`
watchman.pid_check "$cjdroute_control_pid" && {
kill "$cjdroute_control_pid"
watchman.pid_wait "$cjdroute_control_pid"
}
}

View File

@ -1,8 +1,8 @@
#!/usr/bin/env watchman
service_respawn=true
service_command='/usr/bin/dbus-daemon'
service_args='--system'
service_pidfile='/run/dbus/pid'
service_args='--system --nofork'
start_pre() {
/usr/bin/dbus-uuidgen --ensure=/etc/machine-id
@ -13,8 +13,3 @@ start() {
start_pre
watchman.start
}
stop() {
[[ -e "$service_pidfile" ]] && { rm "$service_pidfile"; }
watchman.stop
}

View File

@ -1,7 +1,6 @@
#!/usr/bin/env watchman
# dhcp client daemon initscript
service_respawn=true
service_command='/usr/sbin/dhcpcd'
service_pidfile='/var/run/dhcpcd.pid'
source "${cfg_dir}/conf.d/dhcpcd.sh"
service_args='-B -C resolv.conf'

View File

@ -1,3 +1,4 @@
#!/usr/bin/env watchman
service_respawn=true
service_command='/bin/dropbear'

View File

@ -1,4 +1,5 @@
#!/usr/bin/env watchman
service_respawn=true
service_command='/bin/mpd'
service_pidfile='/run/mpd.pid'
service_args='--no-daemon'

View File

@ -2,6 +2,7 @@
cfg_nrpe_config='/etc/nrpe/nrpe.cfg'
service_respawn=true
service_command='/usr/bin/nrpe'
service_pidfile='/run/nrpe.pid'
service_args=" -c ${cfg_nrpe_config} -d"
service_args="-c ${cfg_nrpe_config} -d"

View File

@ -2,6 +2,6 @@
cfg_ntpd_config='/etc/ntp.conf'
service_respawn='true'
service_command='/bin/ntpd'
service_pidfile='/run/ntpd.pid'
service_args="-c $cfg_ntpd_config -p $service_pidfile"
service_args="-c $cfg_ntpd_config -n"

View File

@ -3,9 +3,9 @@
privoxy_username='privoxy'
privoxy_configfile='/etc/privoxy/config'
service_respawn='true'
service_command='/usr/bin/privoxy'
service_pidfile='/run/privoxy.pid'
service_args="--pidfile ${service_pidfile} --user ${privoxy_username} ${privoxy_configfile}"
service_args="--no-daemon --user ${privoxy_username} ${privoxy_configfile}"
privoxy::configtest() {
"${service_command}" --config-test ${service_args}

View File

@ -2,9 +2,9 @@
cfg_sshd_cfgdir='/etc/ssh'
service_respawn=true
service_command='/bin/sshd'
service_args="-f $cfg_sshd_cfgdir/sshd_config"
service_pidfile='/run/sshd.pid'
service_args="-D -f $cfg_sshd_cfgdir/sshd_config"
sshd_genkeys() {
[[ -e "/etc/ssh/ssh_host_key" ]] || { ssh-keygen -A; }

View File

@ -13,3 +13,9 @@ done
service_type='oneshot'
service_command='/sbin/sysctl'
service_args="-p /etc/sysctl.conf /etc/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf"
start() {
watchman.start
}
unset restart reload

View File

@ -1,4 +1,5 @@
#!/usr/bin/env watchman
service_respawn=true
service_command='/bin/syslog-ng'
service_pidfile='/run/syslog-ng.pid'
service_args='-F'

View File

@ -1,5 +1,5 @@
#!/usr/bin/env watchman
service_respawn=true
service_command='/usr/bin/xinetd'
service_pidfile="/run/xinetd.pid"
service_args="-pidfile $service_pidfile"
service_args='-dontfork'