You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uniffle.apache.org by ro...@apache.org on 2022/08/22 06:08:15 UTC

[incubator-uniffle] branch master updated: PID file name should contain program name (#165)

This is an automated email from the ASF dual-hosted git repository.

roryqi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git


The following commit(s) were added to refs/heads/master by this push:
     new 74cd40b9 PID file name should contain program name (#165)
74cd40b9 is described below

commit 74cd40b9fc5f41b8b04fbaac9bab31985e7b6d15
Author: Junfan Zhang <ju...@outlook.com>
AuthorDate: Mon Aug 22 14:08:10 2022 +0800

    PID file name should contain program name (#165)
    
    ### What changes were proposed in this pull request?
    PID file name with coordinator/shuffle-server tag.
    Once coordinator/shuffle-server process started, the pid file will be generated as
    1. coordinator.pid
    2. shuffle-server.pid
    
    ### Why are the changes needed?
    Original PID file name is `currentpid`, from which, we can't distinguish between coordiantor and server processes
    
    And when I writing the service script to control the coordinator/shuffle-server process, I need the pid name which could be bound to its role.
    
    ### Does this PR introduce _any_ user-facing change?
    No
    
    ### How was this patch tested?
    Manual test.
---
 bin/start-coordinator.sh    |  3 ++-
 bin/start-shuffle-server.sh |  3 ++-
 bin/utils.sh                | 21 +++++++++++++++++++--
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/bin/start-coordinator.sh b/bin/start-coordinator.sh
index 581910d2..6caed9cc 100644
--- a/bin/start-coordinator.sh
+++ b/bin/start-coordinator.sh
@@ -85,4 +85,5 @@ fi
 
 $RUNNER $ARGS $JVM_ARGS -cp $CLASSPATH $MAIN_CLASS --conf $CONF_FILE $@ &
 
-echo $! >$COORDINATOR_HOME/currentpid
+get_pid_file_name coordinator
+echo $! >$COORDINATOR_HOME/${pid_file}
diff --git a/bin/start-shuffle-server.sh b/bin/start-shuffle-server.sh
index 196960c0..7542be4a 100644
--- a/bin/start-shuffle-server.sh
+++ b/bin/start-shuffle-server.sh
@@ -100,4 +100,5 @@ fi
 
 $RUNNER $ARGS $JVM_ARGS $JAVA_LIB_PATH -cp $CLASSPATH $MAIN_CLASS --conf $CONF_FILE $@ &
 
-echo $! >$SHUFFLE_SERVER_HOME/currentpid
+get_pid_file_name shuffle-server
+echo $! >$SHUFFLE_SERVER_HOME/${pid_file}
diff --git a/bin/utils.sh b/bin/utils.sh
index 77b1b874..82922121 100644
--- a/bin/utils.sh
+++ b/bin/utils.sh
@@ -41,18 +41,35 @@ function common_shutdown {
   process_name="$1"
   install_dir="$2"
   max_attempt=30
-  pid=`cat ${install_dir}/currentpid`
+  get_pid_file_name ${process_name}
+  pid_file_name="${pid_file}"
+  pid=`cat ${install_dir}/${pid_file_name}`
 
   kill_process_with_retry "${pid}" "${process_name}" "${max_attempt}"
 
   if [[ $? == 0 ]]; then
-    rm -f ${install_dir}/currentpid
+    rm -f ${install_dir}/${pid_file_name}
     return 0
   else
     return 1
   fi
 }
 
+#---
+# args:               Process name, coordinator or shuffle-server
+#---
+function get_pid_file_name {
+  process_name="$1"
+  if [[ $process_name == "coordinator" ]]; then
+    pid_file="coordinator.pid"
+  elif [[ $process_name == "shuffle-server" ]]; then
+    pid_file="shuffle-server.pid"
+  else
+    echo "Invalid process name: $process_name"
+    exit 1
+  fi
+}
+
 #---
 # kill_process_with_retry: Checks and attempts to kill the running process
 # args:                    PID, process name, number of kill attempts