comparison rc.d/feed-push @ 8:89a371120463 draft

not so easy to track PIDs of python daemons Signed-off-by: Changaco <changaco ατ changaco δοτ net>
author Changaco <changaco ατ changaco δοτ net>
date Mon, 16 Apr 2012 01:10:31 +0200
parents b88065b70ecd
children 8dc405772957
comparison
equal deleted inserted replaced
7:09afbcd3efcb 8:89a371120463
4 . /etc/rc.d/functions 4 . /etc/rc.d/functions
5 5
6 daemon_bin="/usr/bin/feed-push" 6 daemon_bin="/usr/bin/feed-push"
7 daemon_name=$(basename $daemon_bin) 7 daemon_name=$(basename $daemon_bin)
8 pid_file="/var/run/$daemon_name.pid" 8 pid_file="/var/run/$daemon_name.pid"
9 PID=$(cat $pid_file)
9 10
10 data_dir=/var/lib/$daemon_name 11 data_dir=/var/lib/$daemon_name
11 conf_dir=/etc/$daemon_name 12 conf_dir=/etc/$daemon_name
12
13 get_pid() {
14 pgrep -f $daemon_name | grep -v $$
15 }
16 PID=$(get_pid)
17 13
18 case "$1" in 14 case "$1" in
19 start) 15 start)
20 stat_busy "Starting $daemon_name daemon" 16 stat_busy "Starting $daemon_name daemon"
21 if [ -z "$PID" ]; then 17 if [ -z "$PID" ]; then
22 [ -f $pid_file ] && rm -f $pid_file
23 $daemon_bin "$conf_dir" "$data_dir/state" --fork $pid_file --syslog 18 $daemon_bin "$conf_dir" "$data_dir/state" --fork $pid_file --syslog
24 if [ $? -gt 0 ]; then 19 if [ $? -gt 0 ]; then
25 stat_fail 20 stat_fail
26 exit 1 21 exit 1
27 else 22 else