File tree Expand file tree Collapse file tree 2 files changed +78
-3
lines changed Expand file tree Collapse file tree 2 files changed +78
-3
lines changed Original file line number Diff line number Diff line change 1
1
.idea /
2
- src
3
- cbsd-mq-router
4
- log
2
+ . / src
3
+ . / cbsd-mq-router
4
+ . / log
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ # PROVIDE: cbsd_mq_router
4
+ # REQUIRE: NETWORK
5
+ # BEFORE: DAEMON
6
+
7
+ . /etc/rc.subr
8
+
9
+ name=" cbsd_mq_router"
10
+ desc=" CBSD K8S API Module"
11
+ rcvar=" cbsd_mq_router_enable"
12
+ pidfile=" /var/run/${name} .pid"
13
+ daemon_pidfile=" /var/run/${name} -daemon.pid"
14
+ logdir=" /var/log/${name} "
15
+ logfile=" ${logdir} /cbsd_mq_router.log"
16
+ extra_commands=" reload"
17
+ command=" /usr/local/sbin/cbsd-mq-router"
18
+ cbsd_mq_router_config=${cbsd_mq_router_config-" /usr/local/etc/cbsd-mq-router.json" }
19
+ required_files=" ${cbsd_mq_router_config} "
20
+
21
+ cbsd_mq_router_args=${cbsd_mq_router_args-" -config ${cbsd_mq_router_config} " }
22
+
23
+ load_rc_config ${name}
24
+
25
+ start_cmd=" start"
26
+ stop_cmd=" stop"
27
+ status_cmd=" status"
28
+ reload_cmd=" reload"
29
+
30
+ stop ()
31
+ {
32
+ if [ -f " ${daemon_pidfile} " ]; then
33
+ pids=$( pgrep -F ${daemon_pidfile} 2>&1 )
34
+ _err=$?
35
+ [ ${_err} -eq 0 ] && kill -9 ${pids} && /bin/rm -f ${daemon_pidfile}
36
+ fi
37
+ if [ -f " ${pidfile} " ]; then
38
+ pids=$( pgrep -F ${pidfile} 2>&1 )
39
+ _err=$?
40
+ [ ${_err} -eq 0 ] && kill -9 ${pids} && /bin/rm -f ${pidfile}
41
+ fi
42
+ }
43
+
44
+ start ()
45
+ {
46
+ [ ! -d ${logdir} ] && mkdir -p ${logdir}
47
+ touch ${logfile}
48
+ /usr/sbin/daemon -f -R5 -p ${pidfile} -P ${daemon_pidfile} -o ${logfile} ${command} ${cbsd_mq_router_args}
49
+ }
50
+
51
+ reload ()
52
+ {
53
+ stop
54
+ start
55
+ }
56
+
57
+ status ()
58
+ {
59
+ if [ -f " ${pidfile} " ]; then
60
+ pids=$( pgrep -F ${pidfile} 2>&1 )
61
+ _err=$?
62
+ if [ ${_err} -eq 0 ]; then
63
+ echo " ${name} is running as pid ${pids} "
64
+ exit 0
65
+ else
66
+ echo " wrong pid: ${pids} "
67
+ exit 1
68
+ fi
69
+ else
70
+ echo " no pidfile $pidfile "
71
+ exit 1
72
+ fi
73
+ }
74
+
75
+ run_rc_command " $1 "
You can’t perform that action at this time.
0 commit comments