forked from saltstack/salt
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating spec to 0.10.4, patching bug saltstack#2335 (RHBZ#869669)
- Loading branch information
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
From d21f01128f378cd9bbcf59e7436114594ddf08e4 Mon Sep 17 00:00:00 2001 | ||
From: "Jeffrey C. Ollie" <jeff@ocjtech.us> | ||
Date: Tue, 23 Oct 2012 09:20:38 -0500 | ||
Subject: [PATCH] Fix systemd service status. | ||
|
||
Under systemd, not every service has a "Main PID" so using that to | ||
determine whether a service was running failed for a number of useful | ||
cases, especially services that use systemd's init script | ||
compatibility layer. | ||
|
||
Instead, use the 'systemctl is-active' command to determine the status | ||
of a service. | ||
--- | ||
salt/modules/systemd.py | 13 ++++--------- | ||
1 file changed, 4 insertions(+), 9 deletions(-) | ||
|
||
diff --git a/salt/modules/systemd.py b/salt/modules/systemd.py | ||
index 2e37718..185b1d5 100644 | ||
--- a/salt/modules/systemd.py | ||
+++ b/salt/modules/systemd.py | ||
@@ -166,20 +166,15 @@ def reload(name): | ||
# system | ||
def status(name, sig=None): | ||
''' | ||
- Return the status for a service via systemd, returns the PID if the service | ||
- is running or an empty string if the service is not running | ||
+ Return the status for a service via systemd, returns a bool | ||
+ whether the service is running. | ||
|
||
CLI Example:: | ||
|
||
salt '*' service.status <service name> | ||
''' | ||
- ret = __salt__['cmd.run'](_systemctl_cmd('show', name)) | ||
- index1 = ret.find('\nMainPID=') | ||
- index2 = ret.find('\n', index1+9) | ||
- mainpid = ret[index1+9:index2] | ||
- if mainpid == '0': | ||
- return '' | ||
- return mainpid | ||
+ cmd = 'systemctl is-active {0}'.format(name) | ||
+ return not __salt__['cmd.retcode'](cmd) | ||
|
||
|
||
def enable(name): | ||
-- | ||
1.7.11.7 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters