mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add timeout support to the state
Remove redundent net stop command from the stop function Remove extra _enable call on Windows that was causing incorrect state return comments
This commit is contained in:
parent
d579b3e2ef
commit
d44eaeed6c
2 changed files with 7 additions and 14 deletions
|
@ -438,15 +438,6 @@ def stop(name, timeout=90):
|
|||
|
||||
salt '*' service.stop <service name>
|
||||
'''
|
||||
# net stop issues a stop command and waits briefly (~30s), but will give
|
||||
# up if the service takes too long to stop with a misleading
|
||||
# "service could not be stopped" message and RC 0.
|
||||
|
||||
cmd = ['net', 'stop', '/y', name]
|
||||
res = __salt__['cmd.run'](cmd, python_shell=False)
|
||||
if 'service was stopped' in res:
|
||||
return True
|
||||
|
||||
try:
|
||||
win32serviceutil.StopService(name)
|
||||
except pywintypes.error as exc:
|
||||
|
@ -543,7 +534,7 @@ def execute_salt_restart_task():
|
|||
return __salt__['task.run'](name='restart-salt-minion')
|
||||
|
||||
|
||||
def status(name, **kwargs):
|
||||
def status(name, *args, **kwargs):
|
||||
'''
|
||||
Return the status for a service
|
||||
|
||||
|
|
|
@ -434,16 +434,15 @@ def running(name,
|
|||
ret['comment'] = 'Service {0} is set to start'.format(name)
|
||||
return ret
|
||||
|
||||
if salt.utils.is_windows():
|
||||
if enable is True:
|
||||
ret.update(_enable(name, False, result=False, **kwargs))
|
||||
|
||||
# Conditionally add systemd-specific args to call to service.start
|
||||
start_kwargs, warnings = \
|
||||
_get_systemd_only(__salt__['service.start'], locals())
|
||||
if warnings:
|
||||
ret.setdefault('warnings', []).extend(warnings)
|
||||
|
||||
if salt.utils.is_windows() and kwargs.get('timeout', False):
|
||||
start_kwargs.update({'timeout': kwargs.get('timeout')})
|
||||
|
||||
try:
|
||||
func_ret = __salt__['service.start'](name, **start_kwargs)
|
||||
except CommandExecutionError as exc:
|
||||
|
@ -583,6 +582,9 @@ def dead(name,
|
|||
if warnings:
|
||||
ret.setdefault('warnings', []).extend(warnings)
|
||||
|
||||
if salt.utils.is_windows() and kwargs.get('timeout', False):
|
||||
stop_kwargs.update({'timeout': kwargs.get('timeout')})
|
||||
|
||||
func_ret = __salt__['service.stop'](name, **stop_kwargs)
|
||||
if not func_ret:
|
||||
ret['result'] = False
|
||||
|
|
Loading…
Add table
Reference in a new issue