cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaya...@apache.org
Subject [1/2] git commit: updated refs/heads/4.4-forward to 37a3a65
Date Tue, 27 May 2014 05:32:25 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4-forward 2ab7bcade -> 37a3a65c7


CLOUDSTACK-6328: run.sh check if an existing java process is running, before spawining new
ones

Signed-off-by: Jayapal <jayapal@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/587ee544
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/587ee544
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/587ee544

Branch: refs/heads/4.4-forward
Commit: 587ee544f2d8223599e5ee8c56f926ebf7882b8c
Parents: 2ab7bca
Author: Saurav Lahiri <saurav.lahiri@sungard.com>
Authored: Tue Apr 15 12:08:11 2014 +0000
Committer: Jayapal <jayapal@apache.org>
Committed: Tue May 27 10:56:04 2014 +0530

----------------------------------------------------------------------
 systemvm/patches/debian/config/etc/init.d/cloud | 14 ++++-----
 systemvm/scripts/run.sh                         | 30 +++++++++++++++-----
 systemvm/scripts/utils.sh                       | 21 ++++++++++++++
 3 files changed, 50 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/587ee544/systemvm/patches/debian/config/etc/init.d/cloud
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/etc/init.d/cloud b/systemvm/patches/debian/config/etc/init.d/cloud
index 83853bc..b18b8b1 100755
--- a/systemvm/patches/debian/config/etc/init.d/cloud
+++ b/systemvm/patches/debian/config/etc/init.d/cloud
@@ -75,17 +75,15 @@ _failure() {
 }
 RETVAL=$?
 CLOUDSTACK_HOME="/usr/local/cloud"
+if [ -f  $CLOUDSTACK_HOME/systemvm/utils.sh ];
+then
+  . $CLOUDSTACK_HOME/systemvm/utils.sh
+else
+  _failure
+fi
 
 # mkdir -p /var/log/vmops
 
-get_pids() {
-  local i
-  for i in $(ps -ef| grep java | grep -v grep | awk '{print $2}'); 
-  do 
-    echo $(pwdx $i) | grep "$CLOUDSTACK_HOME"  | awk -F: '{print $1}'; 
-  done
-}
-
 start() {
    local pid=$(get_pids)
    if [ "$pid" != "" ]; then

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/587ee544/systemvm/scripts/run.sh
----------------------------------------------------------------------
diff --git a/systemvm/scripts/run.sh b/systemvm/scripts/run.sh
index 146d96f..b6a3a27 100755
--- a/systemvm/scripts/run.sh
+++ b/systemvm/scripts/run.sh
@@ -23,15 +23,31 @@
 #_run.sh runs the agent client.
 
 # set -x
- 
+readonly PROGNAME=$(basename "$0")
+readonly LOCKDIR=/tmp
+readonly LOCKFD=500
+
+CLOUDSTACK_HOME="/usr/local/cloud"
+. $CLOUDSTACK_HOME/systemvm/utils.sh
+
+LOCKFILE=$LOCKDIR/$PROGNAME.xlock
+lock $LOCKFILE $LOCKFD
+if [ $? -eq 1 ];then
+  exit 1
+fi 
+
 while true
 do
-  ./_run.sh "$@" &
-  wait
-  ex=$?
-  if [ $ex -eq 0 ] || [ $ex -eq 1 ] || [ $ex -eq 66 ] || [ $ex -gt 128 ]; then
-      # permanent errors
-      sleep 5
+  pid=$(get_pids)
+  action=`cat /usr/local/cloud/systemvm/user_request`
+  if [ "$pid" == "" ] && [ "$action" == "start" ] ; then
+    ./_run.sh "$@" &
+    wait
+    ex=$?
+    if [ $ex -eq 0 ] || [ $ex -eq 1 ] || [ $ex -eq 66 ] || [ $ex -gt 128 ]; then
+        # permanent errors
+        sleep 5
+    fi
   fi
 
   # user stop agent by service cloud stop

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/587ee544/systemvm/scripts/utils.sh
----------------------------------------------------------------------
diff --git a/systemvm/scripts/utils.sh b/systemvm/scripts/utils.sh
new file mode 100644
index 0000000..4d55fc7
--- /dev/null
+++ b/systemvm/scripts/utils.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+CLOUDSTACK_HOME="/usr/local/cloud"
+
+get_pids() {
+  local i
+  for i in $(ps -ef| grep java | grep -v grep | awk '{print $2}');
+  do
+    echo $(pwdx $i) | grep "$CLOUDSTACK_HOME"  | awk -F: '{print $1}';
+  done
+}
+
+lock()
+{
+  lockfile=$1
+  lockfd=$2
+  eval "exec $lockfd>$lockfile"
+  flock -n $lockfd\
+        && return 0 \
+        || return 1
+}


Mime
View raw message