forked from otale/tale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tale.sh
95 lines (85 loc) · 1.68 KB
/
tale.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
# author:biezhi
# url:https://github.com/otale/scripts
# Usage: sh tale.sh start "-Xms128m -Xmx128m"
# Usage: sh tale.sh stop
# Usage: sh tale.sh status
# Usage: sh tale.sh reload 10
# Usage: sh tale.sh log
env_args="-Xms128m -Xmx128m"
sleeptime=0
arglen=$#
# get tale pid
get_pid(){
pname="`find .. -name 'tale*.jar'`"
pname=${pname:3}
pid=`ps -ef | grep $pname | grep -v grep | awk '{print $2}'`
echo "$pid"
}
startup(){
pid=$(get_pid)
if [ "$pid" != "" ]
then
echo "Tale already startup!"
else
jar_path=`find .. -name 'tale*.jar'`
echo "jarfile=$jar_path"
cmd="java $1 -jar $jar_path > ./tale.out < /dev/null &"
echo "cmd: $cmd"
java $1 -jar $jar_path > ./tale.out < /dev/null &
show_log
fi
}
shut_down(){
pid=$(get_pid)
if [ "$pid" != "" ]
then
kill -9 $pid
echo "Tale is stop!"
else
echo "Tale already stop!"
fi
}
show_log(){
tail -f tale.out
}
show_help(){
echo -e "\r\n\t欢迎使用Tale Blog"
echo -e "\r\nUsage: sh tale.sh start|stop|reload|status|log"
exit
}
show_status(){
pid=$(get_pid)
if [ "$pid" != "" ]
then
echo "Tale is running with pid: $pid"
else
echo "Tale is stop!"
fi
}
if [ $arglen -eq 0 ]
then
show_help
else
if [ "$2" != "" ]
then
env_args="$2"
fi
case "$1" in
"start")
startup "$env_args"
;;
"stop")
shut_down
;;
"reload")
echo "reload"
;;
"status")
show_status
;;
"log")
show_log
;;
esac
fi