Commit f8b05999 authored by Nicolas Wavrant's avatar Nicolas Wavrant

runner: runXXXWithLock calls supervisor instead of basic Popen

parent 35afff13
...@@ -9,11 +9,13 @@ import logging ...@@ -9,11 +9,13 @@ import logging
import md5 import md5
import multiprocessing import multiprocessing
import os import os
import sup_process
import re import re
import shutil import shutil
import thread import thread
import time import time
import urllib import urllib
import xmlrpclib
from xml.dom import minidom from xml.dom import minidom
import xml_marshaller import xml_marshaller
...@@ -319,19 +321,14 @@ def runSoftwareWithLock(config, lock=True): ...@@ -319,19 +321,14 @@ def runSoftwareWithLock(config, lock=True):
os.remove(config['software_log']) os.remove(config['software_log'])
if not updateProxy(config): if not updateProxy(config):
return False return False
slapgrid = Popen([config['slapos'], 'node', 'software', '--all', try:
'--cfg', config['slapos_cfg'], '--pidfile', slapgrid_pid, sup_process.runProcess(config, "slapgrid-sr")
'--verbose', '--logfile', config['software_log']], if lock:
name='slapgrid-sr', stdout=None) sup_process.waitForProcessEnd(config, "slapgrid-sr")
if lock:
slapgrid.wait()
date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
slapgridResultToFile(config, "software", slapgrid.returncode, date)
#Saves the current compile software for re-use #Saves the current compile software for re-use
config_SR_folder(config) config_SR_folder(config)
return ( True if slapgrid.returncode == 0 else False ) return True
else: except xmlrpclib.Fault:
thread.start_new_thread(waitProcess, (config, slapgrid, "software"))
return False return False
...@@ -422,17 +419,12 @@ def runInstanceWithLock(config, lock=True): ...@@ -422,17 +419,12 @@ def runInstanceWithLock(config, lock=True):
os.remove(config['instance_log']) os.remove(config['instance_log'])
if not (updateProxy(config) and requestInstance(config)): if not (updateProxy(config) and requestInstance(config)):
return False return False
slapgrid = Popen([config['slapos'], 'node', 'instance', '--all', try:
'--cfg', config['slapos_cfg'], '--pidfile', slapgrid_pid, sup_process.runProcess(config, "slapgrid-cp")
'--verbose', '--logfile', config['instance_log']], if lock:
name='slapgrid-cp', stdout=None) sup_process.waitForProcessEnd(config, "slapgrid-cp")
if lock: return True
slapgrid.wait() except xmlrpclib.Fault:
date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
slapgridResultToFile(config, "instance", slapgrid.returncode, date)
return ( True if slapgrid.returncode == 0 else False )
else:
thread.start_new_thread(waitProcess, (config, slapgrid, "instance"))
return False return False
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment