cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [42/50] git commit: updated refs/heads/ui-restyle to 06ccb84
Date Fri, 15 Nov 2013 20:03:27 GMT
CLOUDSTACK-5177: Fixed issue with running script from cron job


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

Branch: refs/heads/ui-restyle
Commit: 7dceca5995e18442760fe48f7b3dfbb9955d8d5f
Parents: 9410423
Author: Jayapal <jayapal@apache.org>
Authored: Fri Nov 15 12:04:38 2013 +0530
Committer: Jayapal <jayapal@apache.org>
Committed: Fri Nov 15 12:05:19 2013 +0530

----------------------------------------------------------------------
 .../config/opt/cloud/bin/monitor_service.sh     |  2 +-
 .../debian/config/root/monitorServices.py       | 39 +++++++++-----------
 2 files changed, 19 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7dceca59/systemvm/patches/debian/config/opt/cloud/bin/monitor_service.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/monitor_service.sh b/systemvm/patches/debian/config/opt/cloud/bin/monitor_service.sh
index a2b789c..c4d99d2 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/monitor_service.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/monitor_service.sh
@@ -64,7 +64,7 @@ crontab -l | grep -v  monitorServices.py | crontab -
 create_config $config
 
 #add cron job
-(crontab -l ; echo "*/3 * * * * python /root/monitorServices.py") | crontab -
+(crontab -l ;echo -e "SHELL=/bin/bash\nPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin\n
*/1 * * * * /usr/bin/python /root/monitorServices.py") | crontab -
 
 
 unlock_exit 0 $lock $locked

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7dceca59/systemvm/patches/debian/config/root/monitorServices.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/root/monitorServices.py b/systemvm/patches/debian/config/root/monitorServices.py
index f0c2afe..2cec672 100755
--- a/systemvm/patches/debian/config/root/monitorServices.py
+++ b/systemvm/patches/debian/config/root/monitorServices.py
@@ -62,8 +62,13 @@ def getConfig( config_file_path = "/etc/monitor.conf" ):
     return  process_dict
 
 def printd (msg):
+
     return 0
-    print msg
+
+    f= open(monitor_log,'r+')
+    f.seek(0, 2)
+    f.write(str(msg)+"\n")
+    f.close()
 
 def raisealert(severity, msg, process_name=None):
     #timeStr=str(time.ctime())
@@ -76,12 +81,6 @@ def raisealert(severity, msg, process_name=None):
     pout = Popen(msg, shell=True, stdout=PIPE)
 
 
-    #f= open(monitor_log,'r+')
-    #f.seek(0, 2)
-    #f.write(str(log))
-    #f.close()
-
-
 def isPidMatchPidFile(pidfile, pids):
 
     if pids is None or isinstance(pids,list) != True or len(pids) == 0:
@@ -119,7 +118,7 @@ def checkProcessStatus( process ):
     service_name = process.get('servicename')
     pidfile = process.get('pidfile')
     #temp_out = None
-    restartFailed=0
+    restartFailed=False
     pidFileMatched=1
     cmd=''
     if process_name is None:
@@ -186,34 +185,32 @@ def checkProcessStatus( process ):
                     for pid in pids:
                         cmd = 'kill -9 '+pid;
                         printd(cmd)
-                        Popen(cmd, shell=True, stdout=PIPE)
+                        Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
 
                 cmd = 'service ' + service_name + ' restart'
-                try:
-                    time.sleep(1)
-                    return_val= check_call(cmd , shell=True)
-                except CalledProcessError:
-                    restartFailed=1
-                    msg="service "+ process_name +" restart failed"
-                    printd(msg)
-                    continue
+
+                time.sleep(1)
+                #return_val= check_call(cmd , shell=True)
+
+                cout = Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
+                return_val = cout.wait()
 
                 if return_val == 0:
                     printd("The process" + process_name +" recovered successfully ")
                     msg="The process " +process_name+" is recovered successfully "
-                    raisealert(log.INFO,process_name,msg)
+                    raisealert(log.INFO,msg,process_name)
 
                     break;
                 else:
                     #retry restarting the process for few tries
                     printd("process restart failing trying again ....")
-                    restartFailed=1
+                    restartFailed=True
                     time.sleep(1)
                     continue
         #for end here
 
-        if restartFailed == 1:
-            msg="The process %s recover failed ", process_name;
+        if restartFailed == True:
+            msg="The process %s recover failed "%process_name
             raisealert(log.ALERT,process_name,msg)
 
             printd("Restart failed after number of retries")


Mime
View raw message