Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service issue due to status_command... #8

Open
bradenwright opened this issue Feb 5, 2015 · 4 comments
Open

Service issue due to status_command... #8

bradenwright opened this issue Feb 5, 2015 · 4 comments

Comments

@bradenwright
Copy link

I fixed my own issue but figured I'd leave the detail here. I noticed that I was having issues with using the service and starting/stopping. Issue came down to the fact that "eye info" command always returns 0 whether the app is running or not.

I think the issue can be fixed by changing:
def status_command
"#{node['eye']['bin']} info #{new_resource.service_name}"
end
to
def status_command
"#{node['eye']['bin']} info #{new_resource.service_name} | grep '[[:alnum:]]+ [.]+ (up|starting)'"
end

essentially I tried to match as detailed as possible to make sure that something is starting (if alpha numberic isn't general enough then that part could be cut out.
execute info $SERVICE_NAME | tee /dev/stderr | grep '[[:alnum:]]+ [.]+ (up|starting)' > /dev/null

@bradenwright
Copy link
Author

For completeness sake I'll mention that I ended up editting/overriding the init.d template so that the service command (in linux) and it also fixes using the service resource in chef (otherwise the service resource status command could be given/overridden when the service resource is setup). Only thing I had to change in init.d was the status section. Mine now looks like:

status)
execute info $SERVICE_NAME | tee /dev/stderr | grep '[[:alnum:]]+ [.]+ (up|starting)' > /dev/null
if [ $? -eq 0 ]; then
echo "$SERVICE_NAME is running"
else
echo "$SERVICE_NAME is NOT running"
exit 1
fi
;;

I did a little slight of hand so the linux std still sees the output from eye info command and I can still grep it "| tee /dev/stderr" and then "> /dev/null" is so that line isn't displayed 2x.

I'd be more than happy to do a fork-pull if you're interested

@kostya
Copy link

kostya commented Feb 5, 2015

you can check exit status by eye status process_name

@hamann
Copy link
Owner

hamann commented Feb 18, 2015

@bradenwright yes, I'm interested, thank you!

but one thing.. your regex isn't working for me

$ eye info sauspiel
sauspiel
  unicorn ......................... up  (16:16, 0%, 154Mb, <61804>)
    child-61819 ................... up  (16:16, 7%, 154Mb, <61819>)
    child-61835 ................... up  (16:16, 5%, 157Mb, <61835>)
    child-61840 ................... up  (16:16, 0%, 156Mb, <61840>)
    child-61844 ................... up  (16:16, 3%, 157Mb, <61844>)
    child-61849 ................... up  (16:16, 2%, 157Mb, <61849>)

$ eye info sauspiel  | grep '[[:alnum:]]+ [.]+ (up|starting)'
$ echo $?
1

And there are other states like 'restarting' or 'unmonitored', which aren't handled by your regex

@bradenwright
Copy link
Author

After @kostya suggestion I ended up going with

status)

 execute info $SERVICE_NAME && execute status <%= @process_name %>

I'll take a look at the details of how best to pass the process_name, etc and make a fork pull request since seems like you are interested & it should cover all states as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants