-
Notifications
You must be signed in to change notification settings - Fork 0
/
ss
executable file
·92 lines (72 loc) · 1.5 KB
/
ss
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/sh
PIDFILE="/tmp/skyspark.pid"
OUTFILE="/tmp/skyspark.out"
SKYSPARK="skyspark"
ACT=$1
get_pid() {
if [ -f "${PIDFILE}" ]; then
cat ${PIDFILE}
fi
}
start() {
PID=`get_pid`
if [ -z "${PID}" ]; then
FAN_ENV="util::PathEnv" ${SKYSPARK} -noAuth >> ${OUTFILE} 2>&1 &
PID=$!
echo $PID > $PIDFILE
echo "Started SkySpark (pid $PID)"
else
echo "According to ${PIDFILE}, SkySpark is already running (pid ${PID})"
fi
}
stop() {
PID=`get_pid`
if [ -z "${PID}" ]; then
echo "According to ${PIDFILE}, SkySpark is not running"
else
kill ${PID} \
&& rm ${PIDFILE} \
&& echo "SkySpark stopped"
fi
}
print_status() {
PID=`get_pid`
if [ -z "${PID}" ]; then
echo "SkySpark not running (${PIDFILE} not found or empty)"
else
echo "SkySpark running (pid ${PID})"
fi
}
watch() {
tail -f ${OUTFILE} -n 1000 --retry
}
build() {
fanbuild && ss restart
}
usage() {
cat <<EOF
SkySpark shell launcher.
Usage: `basename $0` <command>
Commands:
start Start SkySpark (unless already running)
stop Stop SkySpark (if running)
status Print SkySpark status
restart Restart SkySpark
watch Watch SkySpark's log
build fanbuild && ss restart
EOF
}
which ${SKYSPARK} >> /dev/null
if [ $? -ne 0 ]; then
echo "Command '${SKYSPARK}' not found. Make sure SKYSPARK_HOME/bin is on PATH."
exit 1
fi
case "${ACT}" in
s|start) start;;
e|stop) stop;;
t|status) print_status;;
r|restart) stop; start;;
w|watch) watch;;
b|build) build;;
*) usage;;
esac