1616# limitations under the License.
1717#
1818
19- #
20- # hugegraph This shell script takes care of starting and stopping
21- # HugeGraphServer.
22- #
23- # chkconfig: - 58 74
24- # description: HugeGraphServer is graph database server. It provides graph \
25- # service by RESTful API consisted with graph, schema, gremlin and other APIs.
26-
27- # ## BEGIN INIT INFO
28- # Provides: HugeGraphServer
29- # Required-Start: $java
30- # Required-Stop: $java
31- # Should-Start: -
32- # Should-Stop: -
33- # Short-Description: start and stop HugeGraphServer
34- # Description: HugeGraphServer is graph database server. It provides graph
35- # service by RESTful API consisted with graph, schema, gremlin
36- # and other APIs.
37- # ## END INIT INFO
19+ # This script is used for starting and stopping HugeGraphServer easily.
20+ # We could copy this file under '/usr/bin' to use it globally
3821
39- # Variables
40- # it requires user to set a fixed abs path manually
22+ # Note: user must set a absolute path below
4123INSTALL_DIR=
4224SERVER_PORT=
4325
44- ${INSTALL_DIR:? " Please set variables 'INSTALL_DIR'" }
45- ${SERVER_PORT:? " Please set variables 'SERVER_PORT'" }
26+ ${INSTALL_DIR:? " Please open the script then set variable 'INSTALL_DIR' manually " }
27+ ${SERVER_PORT:? " Please open the script then set variable 'SERVER_PORT' manually " }
4628
4729BIN_DIR=$INSTALL_DIR /bin
4830SERVER_URL=" http://localhost:${SERVER_PORT} "
4931DETECT_URL=" $SERVER_URL /versions"
32+ EXIT=1
5033
5134# Start the HugeGraphServer
5235start () {
53- echo " Starting HugeGraphServer..."
5436 # Verify if the service is running
55- get_status
56- if [ $? -eq 0 ]; then
57- echo " The service is already running"
37+ if get_status; then
38+ echo " The graph server is already running"
5839 exit 0
5940 else
6041 # Run the service
@@ -64,50 +45,41 @@ start() {
6445 # sleep 10
6546
6647 # Verify if the service is running
67- get_status
68- if [ $? -eq 0 ]; then
69- echo " Service was successfully started"
48+ if get_status; then
49+ echo " Graph server was successfully started"
7050 exit 0
7151 else
72- echo " Failed to start service "
52+ echo " Failed to start graph server "
7353 exit 1
7454 fi
7555 fi
7656}
7757
7858# Stop the MATH
7959stop () {
80- echo " Stopping HugeGraphServer..."
8160 # Verify if the service is running
82- get_status
83- if [ $? -eq 0 ]; then
61+ if get_status; then
8462 # Stop the service
8563 $BIN_DIR /stop-hugegraph.sh
8664
87- # Sleep time before the service verification
88- # sleep 10
89-
9065 # Verify if the service is running
91- get_status
92- if [ $? -eq 0 ]; then
66+ if get_status; then
9367 echo " Failed to stop service"
94- exit 1
9568 else
9669 echo " Service was successfully stopped"
97- exit 0
9870 fi
9971 else
10072 echo " The service is already stopped"
73+ fi
74+
75+ if [[ $EXIT -eq 1 ]]; then
10176 exit 0
10277 fi
10378}
10479
10580# Verify the status of HugeGraphServer
10681status () {
107- echo " Checking status of HugeGraphServer..."
108- # Verify if the HugeGraphServer is running
109- get_status
110- if [ $? -eq 0 ]; then
82+ if get_status; then
11183 echo " Service is running"
11284 exit 0
11385 else
@@ -119,7 +91,7 @@ status() {
11991# Get status of HugeGraphServer to ensure it is alive
12092get_status () {
12193 HTTP_CODE=$( curl -I -s -w " %{http_code}" -o /dev/null $DETECT_URL )
122- if [ $HTTP_CODE = 200 ]; then
94+ if [ " $HTTP_CODE " = 200 ]; then
12395 return 0
12496 else
12597 return 1
@@ -137,12 +109,13 @@ case "$1" in
137109 status)
138110 status
139111 ;;
140- restart|reload)
112+ restart|reload|rs)
113+ EXIT=0
141114 stop
142115 start
143116 ;;
144117 * )
145- echo $" Usage: $0 {start| stop| status| restart|reload}"
118+ echo $" Usage: $0 {start, stop, status, restart|reload|rs }"
146119 exit 1
147120esac
148121exit 0
0 commit comments