Skip to content

Commit 420c336

Browse files
authored
Merge 203931d into 738e98d
2 parents 738e98d + 203931d commit 420c336

File tree

3 files changed

+40
-19
lines changed

3 files changed

+40
-19
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,4 @@ bld/
4747
[Bb]in/
4848
[Oo]bj/
4949
[Ll]og/
50-
[Ll]ogs/
51-
!eventmesh-runtime/bin/*.sh
50+
[Ll]ogs/

eventmesh-runtime/bin/start.sh

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
#
33
# Licensed to Apache Software Foundation (ASF) under one or more contributor
44
# license agreements. See the NOTICE file distributed with
@@ -53,6 +53,13 @@ function get_pid {
5353
local ppid=""
5454
if [ -f ${EVENTMESH_HOME}/bin/pid.file ]; then
5555
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
5663
else
5764
if [[ $OS =~ Msys ]]; then
5865
# 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
8289
elif is_java8 "$(which java)"; then
8390
JAVA="$(which java)"
8491
else
85-
echo -e "ERROR\t java(1.8) not found, operation abort."
92+
echo -e "ERROR\t Java 8 not found, operation abort."
8693
exit 9;
8794
fi
8895

89-
echo "eventmesh use java location= "$JAVA
90-
91-
EVENTMESH_HOME=`cd $(dirname $0)/.. && pwd`
96+
echo "EventMesh use Java location: $JAVA"
9297

98+
EVENTMESH_HOME=$(cd "$(dirname "$0")/.." && pwd)
9399
export EVENTMESH_HOME
94100

95-
export EVENTMESH_LOG_HOME=${EVENTMESH_HOME}/logs
101+
EVENTMESH_LOG_HOME="${EVENTMESH_HOME}/logs"
102+
export EVENTMESH_LOG_HOME
96103

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}"
98105

99106
function make_logs_dir {
100107
if [ ! -e "${EVENTMESH_LOG_HOME}" ]; then mkdir -p "${EVENTMESH_LOG_HOME}"; fi
101108
}
102109

103110
error_exit ()
104111
{
105-
echo "ERROR: $1 !!"
112+
echo -e "ERROR\t $1 !!"
106113
exit 1
107114
}
108115

@@ -148,14 +155,18 @@ JAVA_OPT="${JAVA_OPT} -DeventMeshPluginDir=${EVENTMESH_HOME}/plugin"
148155
#fi
149156

150157
pid=$(get_pid)
158+
if [[ $pid == "ERROR"* ]]; then
159+
echo -e "${pid}"
160+
exit 9
161+
fi
151162
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
154165
fi
155166

156167
make_logs_dir
157168

158-
echo "using jdk[$JAVA]" >> ${EVENTMESH_LOG_HOME}/eventmesh.out
169+
echo "Using JDK[$JAVA]" >> ${EVENTMESH_LOG_HOME}/eventmesh.out
159170

160171

161172
EVENTMESH_MAIN=org.apache.eventmesh.runtime.boot.EventMeshStartup

eventmesh-runtime/bin/stop.sh

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
#
33
# Licensed to Apache Software Foundation (ASF) under one or more contributor
44
# license agreements. See the NOTICE file distributed with
@@ -17,7 +17,7 @@
1717
# specific language governing permissions and limitations
1818
# under the License.
1919

20-
#detect operating system.
20+
# Detect operating system
2121
OS=$(uname)
2222

2323
EVENTMESH_HOME=`cd $(dirname $0)/.. && pwd`
@@ -28,6 +28,13 @@ function get_pid {
2828
local ppid=""
2929
if [ -f ${EVENTMESH_HOME}/bin/pid.file ]; then
3030
ppid=$(cat ${EVENTMESH_HOME}/bin/pid.file)
31+
# If the process does not exist, it indicates that the previous process terminated abnormally.
32+
if [ ! -d /proc/$ppid ]; then
33+
# Remove the residual file and return an error status.
34+
rm ${EVENTMESH_HOME}/bin/pid.file
35+
echo -e "ERROR\t EventMesh process had already terminated unexpectedly before, please check log output."
36+
ppid=""
37+
fi
3138
else
3239
if [[ $OS =~ Msys ]]; then
3340
# There is a Bug on Msys that may not be able to kill the identified process
@@ -44,20 +51,24 @@ function get_pid {
4451
}
4552

4653
pid=$(get_pid)
54+
if [[ $pid == "ERROR"* ]]; then
55+
echo -e "${pid}"
56+
exit 9
57+
fi
4758
if [ -z "$pid" ];then
48-
echo -e "No eventmesh running.."
49-
exit 0;
59+
echo -e "ERROR\t No EventMesh server running."
60+
exit 9
5061
fi
5162

5263
kill ${pid}
53-
echo "Send shutdown request to eventmesh(${pid}) OK"
64+
echo "Send shutdown request to EventMesh(${pid}) OK"
5465

5566
[[ $OS =~ Msys ]] && PS_PARAM=" -W "
5667
stop_timeout=60
5768
for no in $(seq 1 $stop_timeout); do
5869
if ps $PS_PARAM -p "$pid" 2>&1 > /dev/null; then
5970
if [ $no -lt $stop_timeout ]; then
60-
echo "[$no] shutdown server ..."
71+
echo "[$no] server shutting down ..."
6172
sleep 1
6273
continue
6374
fi

0 commit comments

Comments
 (0)