|
1 | | -#!/bin/sh |
| 1 | +#!/bin/bash |
2 | 2 | # |
3 | 3 | # Licensed to Apache Software Foundation (ASF) under one or more contributor |
4 | 4 | # license agreements. See the NOTICE file distributed with |
@@ -53,6 +53,13 @@ function get_pid { |
53 | 53 | local ppid="" |
54 | 54 | if [ -f ${EVENTMESH_HOME}/bin/pid.file ]; then |
55 | 55 | ppid=$(cat ${EVENTMESH_HOME}/bin/pid.file) |
| 56 | + # If the process does not exist, it indicates that the previous process terminated abnormally. |
| 57 | + if [ ! -d /proc/$ppid ]; then |
| 58 | + # Remove the residual file |
| 59 | + rm ${EVENTMESH_HOME}/bin/pid.file |
| 60 | + echo -e "ERROR\t EventMesh process had already terminated unexpectedly before, please check log output." |
| 61 | + ppid="" |
| 62 | + fi |
56 | 63 | else |
57 | 64 | if [[ $OS =~ Msys ]]; then |
58 | 65 | # There is a Bug on Msys that may not be able to kill the identified process |
@@ -82,27 +89,27 @@ elif is_java8 "/nemo/jdk/bin/java"; then |
82 | 89 | elif is_java8 "$(which java)"; then |
83 | 90 | JAVA="$(which java)" |
84 | 91 | else |
85 | | - echo -e "ERROR\t java(1.8) not found, operation abort." |
| 92 | + echo -e "ERROR\t Java 8 not found, operation abort." |
86 | 93 | exit 9; |
87 | 94 | fi |
88 | 95 |
|
89 | | -echo "eventmesh use java location= "$JAVA |
90 | | - |
91 | | -EVENTMESH_HOME=`cd $(dirname $0)/.. && pwd` |
| 96 | +echo "EventMesh use Java location: $JAVA" |
92 | 97 |
|
| 98 | +EVENTMESH_HOME=$(cd "$(dirname "$0")/.." && pwd) |
93 | 99 | export EVENTMESH_HOME |
94 | 100 |
|
95 | | -export EVENTMESH_LOG_HOME=${EVENTMESH_HOME}/logs |
| 101 | +EVENTMESH_LOG_HOME="${EVENTMESH_HOME}/logs" |
| 102 | +export EVENTMESH_LOG_HOME |
96 | 103 |
|
97 | | -echo "EVENTMESH_HOME : ${EVENTMESH_HOME}, EVENTMESH_LOG_HOME : ${EVENTMESH_LOG_HOME}" |
| 104 | +echo -e "EVENTMESH_HOME : ${EVENTMESH_HOME}\nEVENTMESH_LOG_HOME : ${EVENTMESH_LOG_HOME}" |
98 | 105 |
|
99 | 106 | function make_logs_dir { |
100 | 107 | if [ ! -e "${EVENTMESH_LOG_HOME}" ]; then mkdir -p "${EVENTMESH_LOG_HOME}"; fi |
101 | 108 | } |
102 | 109 |
|
103 | 110 | error_exit () |
104 | 111 | { |
105 | | - echo "ERROR: $1 !!" |
| 112 | + echo -e "ERROR\t $1 !!" |
106 | 113 | exit 1 |
107 | 114 | } |
108 | 115 |
|
@@ -148,14 +155,18 @@ JAVA_OPT="${JAVA_OPT} -DeventMeshPluginDir=${EVENTMESH_HOME}/plugin" |
148 | 155 | #fi |
149 | 156 |
|
150 | 157 | pid=$(get_pid) |
| 158 | +if [[ $pid == "ERROR"* ]]; then |
| 159 | + echo -e "${pid}" |
| 160 | + exit 9 |
| 161 | +fi |
151 | 162 | if [ -n "$pid" ];then |
152 | | - echo -e "ERROR\t the server is already running (pid=$pid), there is no need to execute start.sh again." |
153 | | - exit 9; |
| 163 | + echo -e "ERROR\t The server is already running (pid=$pid), there is no need to execute start.sh again." |
| 164 | + exit 9 |
154 | 165 | fi |
155 | 166 |
|
156 | 167 | make_logs_dir |
157 | 168 |
|
158 | | -echo "using jdk[$JAVA]" >> ${EVENTMESH_LOG_HOME}/eventmesh.out |
| 169 | +echo "Using JDK[$JAVA]" >> ${EVENTMESH_LOG_HOME}/eventmesh.out |
159 | 170 |
|
160 | 171 |
|
161 | 172 | EVENTMESH_MAIN=org.apache.eventmesh.runtime.boot.EventMeshStartup |
|
0 commit comments