Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shutdown.sh and match other shell script #7020

Closed
wants to merge 10 commits into from
Closed

Conversation

jgzl
Copy link

@jgzl jgzl commented May 26, 2021

remove shutdown.bat and update shutdown.sh,oapServiceShutdown.sh,webappServiceShutdown.sh match other shell script

@jgzl
Copy link
Author

jgzl commented May 26, 2021

#7011

@codecov
Copy link

codecov bot commented May 26, 2021

Codecov Report

Merging #7020 (73a9ea8) into master (144210b) will decrease coverage by 8.45%.
The diff coverage is n/a.

❗ Current head 73a9ea8 differs from pull request most recent head c900957. Consider uploading reports for the commit c900957 to get more accurate results
Impacted file tree graph

@@             Coverage Diff              @@
##             master    #7020      +/-   ##
============================================
- Coverage     53.14%   44.69%   -8.46%     
+ Complexity     4217     2855    -1362     
============================================
  Files          1865     1852      -13     
  Lines         40319    39892     -427     
  Branches       4510     4658     +148     
============================================
- Hits          21429    17831    -3598     
- Misses        17836    21013    +3177     
+ Partials       1054     1048       -6     
Impacted Files Coverage Δ
...ywalking/apm/agent/core/plugin/EnhanceContext.java 0.00% <0.00%> (-100.00%) ⬇️
...walking/apm/agent/core/plugin/match/NameMatch.java 0.00% <0.00%> (-100.00%) ⬇️
...ng/oap/server/core/analysis/config/NoneStream.java 0.00% <0.00%> (-100.00%) ⬇️
...rver/core/browser/source/BrowserErrorCategory.java 0.00% <0.00%> (-100.00%) ⬇️
...core/browser/source/BrowserAppTrafficCategory.java 0.00% <0.00%> (-100.00%) ⬇️
...gin/interceptor/enhance/MethodInterceptResult.java 0.00% <0.00%> (-100.00%) ⬇️
.../parser/listener/DatabaseSlowStatementBuilder.java 0.00% <0.00%> (-100.00%) ⬇️
...torage/plugin/elasticsearch/base/StorageEsDAO.java 0.00% <0.00%> (-100.00%) ⬇️
...in/elasticsearch/base/TimeRangeIndexNameMaker.java 0.00% <0.00%> (-100.00%) ⬇️
.../provider/parser/performance/PerfDataAnalyzer.java 0.00% <0.00%> (-100.00%) ⬇️
... and 288 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 144210b...c900957. Read the comment docs.

@wu-sheng wu-sheng added backend OAP backend related. enhancement Enhancement on performance or codes labels May 26, 2021
@wu-sheng wu-sheng requested a review from JaredTan95 May 26, 2021 13:05
@wu-sheng
Copy link
Member

@JaredTan95 @innerpeacez Any time to check this script locally? And give a review?

@JaredTan95
Copy link
Member

@JaredTan95 @innerpeacez Any time to check this script locally? And give a review?

Okay, I'll check it locally these days.

dist-material/bin/oapServiceShutdown.sh Outdated Show resolved Hide resolved
if [ $? -eq 0 ]; then
sleep 1
sleep 1
/bin/echo -n $! > "$UI_PID_FILE"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest moving $! to line 39 and give it a variable, in case we add background commands between line 38 and this line, the pid will be wrong

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to give it a variable ,because $! is the PID of the last program your shell ran in the background

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to give it a variable ,because $! is the PID of the last program your shell ran in the background

I know. I mean pid=$!

dist-material/bin/webappServiceShutdown.sh Outdated Show resolved Hide resolved
Comment on lines 48 to 47
echo "SkyWalking OAP started successfully!"
else
echo "SkyWalking OAP started failure!"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep 2 spaces as indentation.

Copy link
Author

@jgzl jgzl Jun 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep 2 spaces as indentation.

I've completed

  echo "SkyWalking OAP started successfully!"
else
  echo "SkyWalking OAP started failure!"
  echo "SkyWalking Web Application started successfully!"
else
  echo "SkyWalking Web Application started failure!"

Copy link
Member

@innerpeacez innerpeacez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is suggested to stop the process by signal.

OAP_PID_FILE="${SW_HOME}/bin/oap.pid"

if [ -f $OAP_PID_FILE ]; then
kill -9 $(cat "$OAP_PID_FILE")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SIGNAL=${SIGNAL:-TERM}
PID=$(cat "$OAP_PID_FILE")
kill -s $SIGNAL $PID

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good suggestion

Copy link
Author

@jgzl jgzl Jun 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've complete

SIGNAL=${SIGNAL:-TERM}
PID=$(cat "$OAP_PID_FILE")
kill -s $SIGNAL $PID

I've complete

OAP_PID_FILE="${SW_HOME}/bin/oap.pid"

if [ -f "$OAP_PID_FILE" ]; then
  SIGNAL=${SIGNAL:-TERM}
  PID=$(cat "$OAP_PID_FILE")
  kill -s "$SIGNAL" "$PID"
  rm "$OAP_PID_FILE"
  echo 'SkyWalking OAP stopped successfully!'
else
  echo 'SkyWalking OAP not exist(could not find file $OAP_PID_FILE)!'
fi

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is: Let the user control the SIGNAL used by himself in a variable way, we only provide a default SIGNAL.

@@ -40,10 +40,14 @@ OAP_OPTIONS=" -Doap.logDir=${OAP_LOG_DIR}"
eval exec "\"$_RUNJAVA\" ${JAVA_OPTS} ${OAP_OPTIONS} -classpath $CLASSPATH org.apache.skywalking.oap.server.starter.OAPServerStartUp \
2>${OAP_LOG_DIR}/oap.log 1> /dev/null &"

PID="$!"
OAP_PID_FILE="${OAP_HOME}/bin/oap.pid"

if [ $? -eq 0 ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$? should be also extracted into variable, now, and should be right after eval exec ...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like this

OAP_PID_FILE="${OAP_HOME}/bin/oap.pid"
eval exec "\"$_RUNJAVA\" ${JAVA_OPTS} ${OAP_OPTIONS} -classpath $CLASSPATH org.apache.skywalking.oap.server.starter.OAPServerStartUp \
        2>${OAP_LOG_DIR}/oap.log 1> /dev/null & /bin/echo -n "$$" > "$OAP_PID_FILE""

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like this

OAP_PID_FILE="${OAP_HOME}/bin/oap.pid"
eval exec "\"$_RUNJAVA\" ${JAVA_OPTS} ${OAP_OPTIONS} -classpath $CLASSPATH org.apache.skywalking.oap.server.starter.OAPServerStartUp \
        2>${OAP_LOG_DIR}/oap.log 1> /dev/null & /bin/echo -n "$$" > "$OAP_PID_FILE""

It's ok, but you have to remove the PID file if $? != 0, right?

Copy link
Author

@jgzl jgzl May 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like this

OAP_PID_FILE="${OAP_HOME}/bin/oap.pid"
eval exec "\"$_RUNJAVA\" ${JAVA_OPTS} ${OAP_OPTIONS} -classpath $CLASSPATH org.apache.skywalking.oap.server.starter.OAPServerStartUp \
        2>${OAP_LOG_DIR}/oap.log 1> /dev/null & /bin/echo -n "$$" > "$OAP_PID_FILE""

It's ok, but you have to remove the PID file if $? != 0, right?

I'm sorry , i didn't test before, this script can't get correct PID. tomcat shell script

  else
    eval $_NOHUP "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER "$JAVA_OPTS" "$CATALINA_OPTS" \
      -D$ENDORSED_PROP="\"$JAVA_ENDORSED_DIRS\"" \
      -classpath "\"$CLASSPATH\"" \
      -Dcatalina.base="\"$CATALINA_BASE\"" \
      -Dcatalina.home="\"$CATALINA_HOME\"" \
      -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
      org.apache.catalina.startup.Bootstrap "$@" start \
      >> "$CATALINA_OUT" 2>&1 "&"

  fi

  if [ ! -z "$CATALINA_PID" ]; then
    echo $! > "$CATALINA_PID"
  fi

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kezhenxu94 Because $! or $$ is used after exec, the PID obtained is the PID of the shell of the child process executed by exec, so the definition of $! can only be defined after the execution of exec. The reference tomcat's startup.sh is also written like this .

  if [ ! -z "$CATALINA_PID" ]; then
    echo $! > "$CATALINA_PID"
  fi

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kezhenxu94 Because $! or $$ is used after exec, the PID obtained is the PID of the shell of the child process executed by exec, so the definition of $! can only be defined after the execution of exec. The reference tomcat's startup.sh is also written like this .

  if [ ! -z "$CATALINA_PID" ]; then
    echo $! > "$CATALINA_PID"
  fi

@wu-sheng
Copy link
Member

@jgzl Any update?

@jgzl
Copy link
Author

jgzl commented Jun 1, 2021

@jgzl Any update?

I didn't update code

@kezhenxu94
Copy link
Member

@jgzl Any update?

I didn't update code

@jgzl We mean, are you still working on this PR or not? because there are some review comments not addressed yet, we can't merge it

@wu-sheng
Copy link
Member

Closing due to no update.

@wu-sheng wu-sheng closed this Jun 24, 2021
@wu-sheng wu-sheng added the invalid The description doesn't fit the case. label Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend OAP backend related. enhancement Enhancement on performance or codes invalid The description doesn't fit the case.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants