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): ...@@ -892,50 +892,21 @@ class Partition(object):
service_list = [] service_list = []
if os.path.exists(self.service_path): if os.path.exists(self.service_path):
if os.path.isdir(self.service_path): if os.path.isdir(self.service_path):
service_list = sorted(os.listdir(self.service_path)) for service in os.listdir(self.service_path):
"""Asks supervisord to check if one of the processes are in the state_list.""" service_list.append(service + '-on-watch')
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 = []
print(service_list) print(service_list)
for process in service_list:
bad_service_list = []
with self.getSupervisorRPC() as supervisor: with self.getSupervisorRPC() as supervisor:
print("Fuck!!!") all_process = supervisor.getAllProcessInfo()
# info = supervisor.getProcessInfo(process_name) print(all_process)
print(info) for process in all_process:
if info['statename'] in state_list: if 'on-watch' in process['name'] and process['statename'] != "RUNNING":
continue self.logger.info('On watch service %r is not running' % process['name'])
# try: bad_service_list.append(process['name'])
# with self.getSupervisorRPC() as supervisor: if len(bad_service_list) > 0:
# print("Fuck!!!") raise ChildProcessError("Some on-watch process is not running!")
# 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.")
def cleanupFolder(self, folder_path): def cleanupFolder(self, folder_path):
"""Delete all files and folders in a specified directory """Delete all files and folders in a specified directory
......
...@@ -1292,9 +1292,6 @@ stderr_logfile_backups=1 ...@@ -1292,9 +1292,6 @@ stderr_logfile_backups=1
if not self.force_stop: if not self.force_stop:
self._checkPromiseList(local_partition) self._checkPromiseList(local_partition)
computer_partition.started() computer_partition.started()
print("******************************")
print("******************************")
print("******************************")
local_partition.checkOnWatchServiceStatus() local_partition.checkOnWatchServiceStatus()
self._endInstallationTransaction(computer_partition) self._endInstallationTransaction(computer_partition)
elif computer_partition_state == COMPUTER_PARTITION_STOPPED_STATE: 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