forked from CodisLabs/codis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codis-server-admin.sh
executable file
·69 lines (59 loc) · 1.68 KB
/
codis-server-admin.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
68
69
#!/usr/bin/env bash
CODIS_ADMIN="${BASH_SOURCE-$0}"
CODIS_ADMIN="$(dirname "${CODIS_ADMIN}")"
CODIS_ADMIN_DIR="$(cd "${CODIS_ADMIN}"; pwd)"
CODIS_BIN_DIR=$CODIS_ADMIN_DIR/../bin
CODIS_LOG_DIR=$CODIS_ADMIN_DIR/../log
CODIS_CONF_DIR=$CODIS_ADMIN_DIR/../config
CODIS_SERVER_BIN=$CODIS_BIN_DIR/codis-server
CODIS_SERVER_PID_FILE=/tmp/redis_6379.pid
CODIS_SERVER_LOG_FILE=/tmp/redis_6379.log
CODIS_SERVER_DAEMON_FILE=$CODIS_LOG_DIR/codis-server.out
CODIS_SERVER_CONF_FILE=$CODIS_CONF_DIR/redis.conf
echo $CODIS_SERVER_CONF_FILE
if [ ! -d $CODIS_LOG_DIR ]; then
mkdir -p $CODIS_LOG_DIR
fi
case $1 in
start)
echo "starting codis-server ... "
if [ -f "$CODIS_SERVER_PID_FILE" ]; then
if kill -0 `cat "$CODIS_SERVER_PID_FILE"` > /dev/null 2>&1; then
echo $command already running as process `cat "$CODIS_SERVER_PID_FILE"`.
exit 0
fi
fi
nohup "$CODIS_SERVER_BIN" "${CODIS_SERVER_CONF_FILE}" > "$CODIS_SERVER_DAEMON_FILE" 2>&1 < /dev/null &
;;
stop)
echo "stopping codis-server ... "
if [ ! -f "$CODIS_SERVER_PID_FILE" ]
then
echo "no codis-server to stop (could not find file $CODIS_SERVER_PID_FILE)"
else
kill -2 $(cat "$CODIS_SERVER_PID_FILE")
echo STOPPED
fi
exit 0
;;
stop-forced)
echo "stopping codis-server ... "
if [ ! -f "$CODIS_SERVER_PID_FILE" ]
then
echo "no codis-server to stop (could not find file $CODIS_SERVER_PID_FILE)"
else
kill -9 $(cat "$CODIS_SERVER_PID_FILE")
rm "$CODIS_SERVER_PID_FILE"
echo STOPPED
fi
exit 0
;;
restart)
shift
"$0" stop
sleep 1
"$0" start
;;
*)
echo "Usage: $0 {start|stop|stop-forced|restart}" >&2
esac