Skip to content

Commit

Permalink
Merge 203931d into 738e98d
Browse files Browse the repository at this point in the history
  • Loading branch information
Pil0tXia committed Aug 24, 2023
2 parents 738e98d + 203931d commit 420c336
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 19 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,4 @@ bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
!eventmesh-runtime/bin/*.sh
[Ll]ogs/
33 changes: 22 additions & 11 deletions eventmesh-runtime/bin/start.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Licensed to Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with
Expand Down Expand Up @@ -53,6 +53,13 @@ function get_pid {
local ppid=""
if [ -f ${EVENTMESH_HOME}/bin/pid.file ]; then
ppid=$(cat ${EVENTMESH_HOME}/bin/pid.file)
# If the process does not exist, it indicates that the previous process terminated abnormally.
if [ ! -d /proc/$ppid ]; then
# Remove the residual file
rm ${EVENTMESH_HOME}/bin/pid.file
echo -e "ERROR\t EventMesh process had already terminated unexpectedly before, please check log output."
ppid=""
fi
else
if [[ $OS =~ Msys ]]; then
# There is a Bug on Msys that may not be able to kill the identified process
Expand Down Expand Up @@ -82,27 +89,27 @@ elif is_java8 "/nemo/jdk/bin/java"; then
elif is_java8 "$(which java)"; then
JAVA="$(which java)"
else
echo -e "ERROR\t java(1.8) not found, operation abort."
echo -e "ERROR\t Java 8 not found, operation abort."
exit 9;
fi

echo "eventmesh use java location= "$JAVA

EVENTMESH_HOME=`cd $(dirname $0)/.. && pwd`
echo "EventMesh use Java location: $JAVA"

EVENTMESH_HOME=$(cd "$(dirname "$0")/.." && pwd)
export EVENTMESH_HOME

export EVENTMESH_LOG_HOME=${EVENTMESH_HOME}/logs
EVENTMESH_LOG_HOME="${EVENTMESH_HOME}/logs"
export EVENTMESH_LOG_HOME

echo "EVENTMESH_HOME : ${EVENTMESH_HOME}, EVENTMESH_LOG_HOME : ${EVENTMESH_LOG_HOME}"
echo -e "EVENTMESH_HOME : ${EVENTMESH_HOME}\nEVENTMESH_LOG_HOME : ${EVENTMESH_LOG_HOME}"

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

error_exit ()
{
echo "ERROR: $1 !!"
echo -e "ERROR\t $1 !!"
exit 1
}

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

pid=$(get_pid)
if [[ $pid == "ERROR"* ]]; then
echo -e "${pid}"
exit 9
fi
if [ -n "$pid" ];then
echo -e "ERROR\t the server is already running (pid=$pid), there is no need to execute start.sh again."
exit 9;
echo -e "ERROR\t The server is already running (pid=$pid), there is no need to execute start.sh again."
exit 9
fi

make_logs_dir

echo "using jdk[$JAVA]" >> ${EVENTMESH_LOG_HOME}/eventmesh.out
echo "Using JDK[$JAVA]" >> ${EVENTMESH_LOG_HOME}/eventmesh.out


EVENTMESH_MAIN=org.apache.eventmesh.runtime.boot.EventMeshStartup
Expand Down
23 changes: 17 additions & 6 deletions eventmesh-runtime/bin/stop.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Licensed to Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with
Expand All @@ -17,7 +17,7 @@
# specific language governing permissions and limitations
# under the License.

#detect operating system.
# Detect operating system
OS=$(uname)

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

pid=$(get_pid)
if [[ $pid == "ERROR"* ]]; then
echo -e "${pid}"
exit 9
fi
if [ -z "$pid" ];then
echo -e "No eventmesh running.."
exit 0;
echo -e "ERROR\t No EventMesh server running."
exit 9
fi

kill ${pid}
echo "Send shutdown request to eventmesh(${pid}) OK"
echo "Send shutdown request to EventMesh(${pid}) OK"

[[ $OS =~ Msys ]] && PS_PARAM=" -W "
stop_timeout=60
for no in $(seq 1 $stop_timeout); do
if ps $PS_PARAM -p "$pid" 2>&1 > /dev/null; then
if [ $no -lt $stop_timeout ]; then
echo "[$no] shutdown server ..."
echo "[$no] server shutting down ..."
sleep 1
continue
fi
Expand Down

0 comments on commit 420c336

Please sign in to comment.