Commit 930cfecb authored by Boxiang Sun's avatar Boxiang Sun

Raise error if any on-watch service is not running

parent d551228a
......@@ -892,50 +892,21 @@ class Partition(object):
service_list = []
if os.path.exists(self.service_path):
if os.path.isdir(self.service_path):
service_list = sorted(os.listdir(self.service_path))
"""Asks supervisord to check if one of the processes are in the state_list."""
service_list = []
print(os.listdir(self.service_path))
state_list = ['RUNNING',]
try:
output = subprocess.check_output(['slapos', 'node', 'status'])
except Exception as e:
output = str(e.output)
content = output.split('\\n')
for line in content:
# print(line)
tokens = line.split(' ')
# print(service_name)
if 'on-watch' in tokens[0]:
service_name = tokens[0].split(':')[1]
# print(service_name)
service_list.append(service_name)
bad_service_list = []
for service in os.listdir(self.service_path):
service_list.append(service + '-on-watch')
print(service_list)
for process in service_list:
with self.getSupervisorRPC() as supervisor:
print("Fuck!!!")
# info = supervisor.getProcessInfo(process_name)
print(info)
if info['statename'] in state_list:
continue
# try:
# with self.getSupervisorRPC() as supervisor:
# print("Fuck!!!")
# info = supervisor.getProcessInfo(process_name)
# print(info)
# if info['statename'] in state_list:
# continue
# except xmlrpclib.Fault as exc:
# print(exc)
# if exc.faultString.startswith('BAD_NAME:'):
# self.logger.debug("BAD process name: %r" % process_name)
# print("Service name is incorrect: %r" % process_name)
# continue
# else:
# print("Service %r is not running." % process_name)
# else:
# print("All on-watch services are running.")
bad_service_list = []
with self.getSupervisorRPC() as supervisor:
all_process = supervisor.getAllProcessInfo()
print(all_process)
for process in all_process:
if 'on-watch' in process['name'] and process['statename'] != "RUNNING":
self.logger.info('On watch service %r is not running' % process['name'])
bad_service_list.append(process['name'])
if len(bad_service_list) > 0:
raise ChildProcessError("Some on-watch process is not running!")
def cleanupFolder(self, folder_path):
"""Delete all files and folders in a specified directory
......
......@@ -1292,9 +1292,6 @@ stderr_logfile_backups=1
if not self.force_stop:
self._checkPromiseList(local_partition)
computer_partition.started()
print("******************************")
print("******************************")
print("******************************")
local_partition.checkOnWatchServiceStatus()
self._endInstallationTransaction(computer_partition)
elif computer_partition_state == COMPUTER_PARTITION_STOPPED_STATE:
......
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