Fix checking for service started status on Debian#6
Conversation
`service SERVICE_NAME status` should return a 0 exit code when running, or non-zero when not running. Piping into grep swallows this, and serves no apparent purpose. This results in services *always* appearing running as long as the command outputs something including 'running' to stdout, including strings like 'SERVICE_NAME is not running'.
|
Upstart base services return exit code 0 even if they are stopped. For example, So you cannot know whether service is running or not only with exit code. Please see mizzy/serverspec#130 |
|
So what happens when using SysV, which is what Debian still uses (not Ubuntu)? This isn't resolved, I'd appreciate the issue being left open until we figure out how to fix this since it's a real bug. |
|
OK, I will reopen this issue. |
|
I don't use Debian, so I don't know the detail of this problem.But removing the lines breaks the compatibility, so please fix it by another way. |
|
I guess if we can assume Ubuntu is always Upstart and Debian is always SysV, we could implement a Ubuntu provider and move this there... Does that sound like an acceptable solution? @bklang, thoughts? |
Upstart does not return non-zero when a service is not running, so must grep for 'running'. On debian, this hides services that are not running but which log something like "not running".
|
How does that solution look? |
|
Thanks! It seems good to me. |
Fix checking for service started status on Debian
|
I've just released as v0.0.7. Thanks! |
|
Not all init scripts return 'running,' so this doesn't work for all cases. |
|
Patches are welcome. |
|
Easy fix: also check for "done", as init scripts are supposed to use the lsb functions, and check out line 118 here http://apt-browse.org/browse/ubuntu/trusty/main/all/lsb-base/4.1%2BDebian11ubuntu6/file/lib/lsb/init-functions.d/50-ubuntu-logging |
Add some dependencies to gemspec
service SERVICE_NAME statusshould return a 0 exit code when running, or non-zero when not running. Piping into grep swallows this, and serves no apparent purpose. This results in services always appearing running as long as the command outputs something including 'running' to stdout, including strings like 'SERVICE_NAME is not running'.