allow to explicit restart service even if not enabled
This commit is contained in:
parent
29c1256ee1
commit
cc206f6198
@ -12,6 +12,9 @@ import sau.platforms
|
||||
|
||||
proc_fd_map_re = re.compile(r'^.*(/(?:usr|lib|opt|etc|s?bin)[^\(]*) \(deleted\)$')
|
||||
|
||||
valid_service_policies=('restart', 'warn', 'ignore', 'silent-restart',
|
||||
'reboot', 'silent-reboot')
|
||||
|
||||
def _warn(policy, msg):
|
||||
log = logging.getLogger(sau.LOGNAME)
|
||||
if not policy.startswith('silent'):
|
||||
@ -182,7 +185,7 @@ def _get_service_restart_policy(service):
|
||||
log = logging.getLogger(sau.LOGNAME)
|
||||
conf = sau.config
|
||||
policy = conf.get('services', service, fallback=None)
|
||||
if policy and policy.lower() in ('restart', 'warn', 'ignore', 'silent-restart', 'reboot', 'silent-reboot'):
|
||||
if policy and policy.lower() in valid_service_policies:
|
||||
return policy.lower()
|
||||
elif policy:
|
||||
log.warning('service policy {} for {} is invalid'.format(policy, service))
|
||||
@ -230,6 +233,9 @@ def _get_service_from_proc(proc):
|
||||
log.warning(f'Not restarting user service {unit}; please log out and log in again')
|
||||
return None
|
||||
else:
|
||||
policy = conf.get('services', name, fallback=None)
|
||||
if policy and policy.lower() in valid_service_policies:
|
||||
return name
|
||||
_ret, enabled, _err = sau.helpers.exec_cmd([ '/usr/bin/systemctl', 'is-enabled', unit ])
|
||||
enabled = enabled.strip()
|
||||
if enabled not in ('enabled', 'static'):
|
||||
|
Loading…
Reference in New Issue
Block a user