forked from CNSRE/Plog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plog.init
69 lines (62 loc) · 1.08 KB
/
plog.init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# Source function library.
# chkconfig: 2345 10 90
# description: plog ....
. /etc/rc.d/init.d/functions
base_dir=/home/xxxx/project/Plog
prog=plog
plog="python ${base_dir}/plog.py"
CONFIG=${base_dir}/${prog}.conf
pid_file=/var/run/${prog}.pid
RETVAL=0
get_pid()
{
cat "$pid_file"
}
is_running()
{
[ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1
}
start()
{
echo -n $"Starting ${prog}: "
${plog} -c ${CONFIG} &
pid=$!
RETVAL=$?
echo $! > $pid_file
if ! is_running; then
failure
else
success
fi
echo
return $RETVAL
}
stop()
{
echo -n $"Stopping ${prog}: "
killproc -p ${pid_file} ${prog}
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pid_file} ${prog}
RETVAL=$?
;;
restart)
stop
start
;;
*)
echo $"Usage: ${prog} {start|stop|restart|status}"
RETVAL=2
esac
exit $RETVAL