You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@predictionio.apache.org by em...@apache.org on 2019/11/05 16:21:51 UTC
[predictionio] branch develop updated: [PIO-200] Improve redeploy
script example (#504)
This is an automated email from the ASF dual-hosted git repository.
emergentorder pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/predictionio.git
The following commit(s) were added to refs/heads/develop by this push:
new d6bae3a [PIO-200] Improve redeploy script example (#504)
d6bae3a is described below
commit d6bae3a725f7d6395d11c73deb5d489296ef2fd9
Author: Vinay <qu...@gmail.com>
AuthorDate: Tue Nov 5 21:03:25 2019 +0530
[PIO-200] Improve redeploy script example (#504)
* [PIO-200] Improve redeploy script example
* [PIO-200] Change to contextually accurate name DEPLOYEDPID
---
examples/redeploy-script/redeploy.sh | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/examples/redeploy-script/redeploy.sh b/examples/redeploy-script/redeploy.sh
index 157afd9..a715229 100755
--- a/examples/redeploy-script/redeploy.sh
+++ b/examples/redeploy-script/redeploy.sh
@@ -155,6 +155,10 @@ if [[ $TRAIN_RESULT -ne 0 ]]; then
fi
# Deploy
+# Get current running instance PID
+PIDBYPORT_COMMAND="lsof -t -i:$PORT"
+DEPLOYEDPID=$($PIDBYPORT_COMMAND)
+
DEPLOY_LOG=`mktemp $LOG_DIR/tmp.XXXXXXXXXX`
$($DEPLOY_COMMAND 1>$DEPLOY_LOG 2>&1) &
@@ -170,6 +174,16 @@ while [[ $RETURN_VAL -ne 0 && $COUNTER -lt 20 ]]; do
let COUNTER=COUNTER+1
done
+# Check if the previous engine instance is running
+KILLSD_COMMAND="kill $DEPLOYEDPID"
+if [ -z "$DEPLOYEDPID" ]
+then
+ printf "\nNo stale PIDs found for port $PORT\n"
+else
+ $($KILLSD_COMMAND)
+ printf "\nStale PID found as $DEPLOYEDPID. Resources released.\n"
+fi
+
cat $DEPLOY_LOG >> $LOG_FILE
rm $DEPLOY_LOG
echo -n "Deploy ended with return value $TRAIN_RESULT at " | tee -a $LOG_FILE