finally fixed!

This commit is contained in:
Fredrik Eriksson 2019-06-23 19:05:22 +02:00
parent 8bd3148a66
commit db9eab4660
No known key found for this signature in database
GPG Key ID: 8825C73A0FD1502A

View File

@ -95,6 +95,7 @@ def restart_services():
for proc in service_procs: for proc in service_procs:
try: try:
service_exe = proc.exe() service_exe = proc.exe()
proc_name = proc.name()
except (psutil.NoSuchProcess, psutil.ZombieProcess, psutil.AccessDenied): except (psutil.NoSuchProcess, psutil.ZombieProcess, psutil.AccessDenied):
log.debug('{} died before it could be restarted'.format(proc)) log.debug('{} died before it could be restarted'.format(proc))
continue continue
@ -115,7 +116,6 @@ def restart_services():
elif policy == 'warn': elif policy == 'warn':
log.warning('Service "{}" has open deleted files and should be restarted'.format(service)) log.warning('Service "{}" has open deleted files and should be restarted'.format(service))
continue continue
if not policy.startswith('silent'): if not policy.startswith('silent'):
log.warning('Restarting service {}'.format(service)) log.warning('Restarting service {}'.format(service))
platform.restart_service(service) platform.restart_service(service)
@ -123,15 +123,13 @@ def restart_services():
recommend_restart = False recommend_restart = False
tested_parents = set() tested_parents = set()
for proc in retest_procs: for proc in retest_procs:
try:
name = proc.name()
except (psutil.NoSuchProcess, psutil.ZombieProcess, psutil.AccessDenied):
log.debug('{} was successfully killed'.format(proc))
continue
parent = _get_top_parent(proc) parent = _get_top_parent(proc)
parent_name = parent.name()
if parent in tested_parents: if parent in tested_parents:
log.debug('{} belongs to already tested parent {}'.format(proc, parent)) log.debug('{} belongs to already tested parent {}'.format(proc, parent))
continue continue
if not parent:
continue
if _get_deleted_open_files(proc): if _get_deleted_open_files(proc):
tested_parents.add(parent) tested_parents.add(parent)
@ -141,12 +139,14 @@ def restart_services():
recommend_restart = True recommend_restart = True
continue continue
if service in services and not services[service]: log.debug('{} is in service {}'.format(proc, service))
if parent_name in services and not services[parent_name]:
log.warning('{} (parent {}) does not belong to a service and could not be restarted'.format(proc, parent)) log.warning('{} (parent {}) does not belong to a service and could not be restarted'.format(proc, parent))
recommend_restart = True recommend_restart = True
continue continue
elif service in services: elif parent_name in services:
policy = _get_service_restart_policy(service) policy = _get_service_restart_policy(service)
log.debug('service {} has policy {}'.format(service, policy))
if policy in ('ignore', 'warn'): if policy in ('ignore', 'warn'):
continue continue
log.warning('{} (parent {}) still has deleted files open'.format(proc, parent)) log.warning('{} (parent {}) still has deleted files open'.format(proc, parent))