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

Zeus ignores exit status of its commands #252

Closed
turadg opened this issue Feb 2, 2013 · 11 comments
Closed

Zeus ignores exit status of its commands #252

turadg opened this issue Feb 2, 2013 · 11 comments
Assignees
Labels

Comments

@turadg
Copy link
Collaborator

turadg commented Feb 2, 2013

Description of Problem

When Zeus runs a command from a plan and it exits with an exit code, that is lost by the time it returns back to the shell. That's the cause of #198 and is posing problems for Zeus with Guard (a major use case).

Steps to Reproduce

  1. Add this method to a custom plan and include in zeus.json:
  def exit_99
    exit 99
  end
  1. run this in the shell:
zeus exit_99
echo $?

Observed Behavior

The shell shows 1 as the exit status code even though Ruby exited with 99. (It seems to return 1 no matter what the Ruby exit code.)

Expected Behavior

That the zeus shell command returns whatever Ruby's Kernel.exit was passed.

@ghost ghost assigned burke Feb 2, 2013
@andyl
Copy link
Contributor

andyl commented Feb 9, 2013

I have this problem also. I run zeus from a test shell. The incorrect status codes break the shell alerting function.

@rafael
Copy link

rafael commented Feb 16, 2013

I'm having this issue as well. Zeus is returning 1 when it should return 0.

@andyl
Copy link
Contributor

andyl commented Feb 17, 2013

Seems like the exit-status is generated by 'zeus/build/zeus-linux-386', which is a binary file (a go executable?). So I don't think its possible to fix this problem in the field. (without getting hands-on with go...)

@turadg
Copy link
Collaborator Author

turadg commented Feb 17, 2013

@andyl, that's right, and why I'm hoping @burke can take a look into it.
Few Ruby devs know Go.

That fact is one reason Spring may
be a better long-term solution.

On Sat, Feb 16, 2013 at 5:55 PM, andyl notifications@github.com wrote:

Seems like the exit-status is generated by 'zeus/build/zeus-linux-386',
which is a binary file (a go executable?). So I don't think its possible to
fix this problem in the field. (without getting hands-on with go...)


Reply to this email directly or view it on GitHubhttps://github.com//issues/252#issuecomment-13678449.

@andyl
Copy link
Contributor

andyl commented Feb 17, 2013

Spring looks nice! Thanks for that reference.

But Spring also ignores the exit status. (rails/spring#57)

I prefer the zeus style of pre-loading. Come on @burke - we need your Go skills!

@turadg
Copy link
Collaborator Author

turadg commented Mar 2, 2013

For the record, @jonleightonfixed fixed that 5 days after you reported it in the Spring repo.

@antifuchs
Copy link
Collaborator

I traced zeusclient.go a bit, and this appears to happen because it's getting a TERM signal.

Right now, I believe this is actually a ruby issue - rubygem/lib/zeus.rb has an at_exit line that kills the client with TERM when the command terminates. My hypothesis right now is that this causes a race condition where zeusclient can't read the exit code from the socket fast enough, and ends up receiving the async signal before it can itself exit with the right exit code.

Removing that at_exit line seems safe, but might be useful to have a safeguard in there to prevent the go client from hanging (though in my experience, that is the least breakage-happy part (-:). I'll read some more code and try to figure out the right way to proceed.

@turadg
Copy link
Collaborator Author

turadg commented Mar 3, 2013

@antifuchs looks like you've succeeded at fixing this!

It's exiting correctly for me now, and I didn't even have to require 'set'. I want to release a 0.13.3.rc2 but for some reason whenever I change the VERSION, the resulting gem produces a broken Zeus (crashes on start). I haven't been able to figure it out. Any ideas?

@turadg turadg closed this as completed Mar 3, 2013
@antifuchs
Copy link
Collaborator

@turadg that's weird - I built the (patched) gem that we use at work by following these steps:

  • I edited ./VERSION to say "0.13.2.2"
  • I ran "make clean darwin",
  • then built the linux zeus on a linux box with the i386/x86_64 go toolchain installed, copied that into build/,
  • then ran "make gem".

The resulting gem does work for me without crashing... to make things a bit easier (no need to install the gem), you should be able to run just the zeus binary out of the build/ dir - what error messages are you getting and what are the relevant versions of tools you're using? I'm on go1.0.3, ruby 1.9.3p362 (via rbenv).

@turadg
Copy link
Collaborator Author

turadg commented Mar 4, 2013

@antifuchs, good idea to run from build/. The problem is before the Gem making. I'm trying to isolate it:

cd $GOPATH/src/github.com/burke/
rm -rf zeus
git clone git@github.com:burke/zeus.git
cd zeus
make darwin manpages

cd somerailsproject
$GOPATH/src/github.com/burke/zeus/build/zeus-darwin-amd64 init
$GOPATH/src/github.com/burke/zeus/build/zeus-darwin-amd64 start

That starts Zeus but the bottom of the terminal briefly says "exit status 1" in white. Then it refreshes, to clear that but all forks stay yellow (waiting) except for boot which stays magenta (connecting).

That's with ruby 1.9.3p374 (via rbenv) and same go1.0.3. Xcode 4.6 with latest command line tools. At least now the problem appears whether I'm changing the VERSION or not, which was weird.

I'd like to get this the new gem into people's hands. If you build a 0.13.3.rc2 and send it to me, I'll push it. Or maybe @burke will build and push it, or grant you access to push.

@antifuchs
Copy link
Collaborator

@turadg I opened #274 for this - guess we should discuss there. I'll be a bit busy with admin stuff today, but will try to get something built that you can test. (:

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

No branches or pull requests

5 participants