-
Notifications
You must be signed in to change notification settings - Fork 0
/
liner.sh
executable file
·67 lines (58 loc) · 1.21 KB
/
liner.sh
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
#!/bin/sh
#
# /etc/rc.d/init.d/liner
#
# liner daemon
#
# chkconfig: 2345 95 05
# description: a liner script
### BEGIN INIT INFO
# Provides: liner
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: liner
# Description: liner
### END INIT INFO
cd "$(dirname "$0")"
test -f .env && . $(pwd -P)/.env
_start() {
setcap 'cap_net_bind_service=ep' liner
test $(ulimit -n) -lt 100000 && ulimit -n 100000
(env ENV=${ENV:-development} is_supervisor_process=1 $(pwd)/liner) <&- >liner.error.log 2>&1 &
local pid=$!
echo -n "Starting liner(${pid}): "
sleep 1
if (ps ax 2>/dev/null || ps) | grep "${pid} " >/dev/null 2>&1; then
echo "OK"
else
echo "Failed"
fi
}
_stop() {
local pid="$(pidof liner)"
if test -n "${pid}"; then
echo -n "Stopping liner(${pid}): "
if kill ${pid}; then
echo "OK"
else
echo "Failed"
fi
fi
}
_restart() {
_stop
sleep 1
_start
}
_reload() {
pkill -HUP -o -x liner
}
_usage() {
echo "Usage: [sudo] $(basename "$0") {start|stop|reload|restart}" >&2
exit 1
}
_${1:-usage}