-
Notifications
You must be signed in to change notification settings - Fork 66
Unable to redirect output from the "ml" script using stanard methods #543
Comments
"Suggest a Fix" Update 1 - 2015/10/29 @ 18:20 |
"Suggest a Fix" Update 2: UPDATED to reference corrected PR submitted to dev branch |
Interesting. When I do @paxtonhare any reason to think this would be a problem? |
Jenkins does not directly invoke Roxy commands. It invokes a bash script which invokes Roxy command: #!/bin/bash
set -e
SCRIPT_PATH=$0
...
echo "Bootstrap = ${ROXY-OPTIONS}"
./ml ${ML_ENVIRONMENT} bootstrap ${ROXY_OPTIONS} The same behavior can be reproduced in Windows / Cygwin. |
also added unique return codes to ml script from deploy/lib/ml.rb deploy/lib/ml.rb All calls to 'exit!' and 'exit' replaced with a unique 'exit #' NOTE SMALL BEHAVIOR CHANGE: 'exit' alone returned 0, now returns # ml Return unique exit code from deploy/lib/ml.rb instead of generalizing to 1 when an error is encountered For more information reference issue marklogic-community#543: marklogic-community#543
@dmcassel it is very strange. Our guess was that STDERR/STDOUT from the logger is dumped in a different way during a typical SystemExit, but the hard exit bypassed that dump. That still didn't explain why we couldn't capture it using a few different methods even though it appears to be returned (in any case the goal was not to capture the output but to see it in Jenkins). Re: |
@paxtonhare As best I can tell this should be completely transparent as I didn't see anything else referencing specific return codes from ml.rb. The only potential concern we could speculate about was if you're handling normal exit behavior in some abstract way...which I'm guessing is not likely. It is specifically SystemExit which is being bypassed. See: exit vs. exit! |
Thanks for digging in to this. On Saturday, October 31, 2015, danielritchie notifications@github.com
|
Just to check -- have you tried directing stderr to your output file as well? |
Yes, and we did find ways where we were able to redirect it. There is another complication which @rlouapre also mentioned: Jenkins executes this VIA a script and is not capturing the output. Although this shouldn't make a difference, we have an additional need for this to show up in Jenkins' console (which typically captures stderr and stdout without any special handling). I came across this article which explains that exit! is considered to be the dangerous version of exit. I thought there may be merit for the big hammer (bypassing SystemExit/at_exit/ensure/rescue/etc.), but I could not determine that there would be any functional change in behavior between the use of "exit!" and "exit 1". As a result replacing the "exit!" calls with "exit" appeared to be the most straightforward way of addressing our issue. This also resolved all unexplained behavior. A bonus was that any impact appears to be positive (who doesn't like deterministic error codes?). FWIW, I did find in the Ruby Language Reference Manual that exit! is "used to terminate sub-processes after calling fork". Past this I had difficulty finding instances where the use of "exit!" was favored over "exit" We appreciate you guys taking the time to take a look at this. Thanks for making roxy available! |
Capture/redirect on exit and provide unique return codes, fix for issue #543
I accepted the PR onto the dev branch. |
also added unique return codes to ml script from deploy/lib/ml.rb deploy/lib/ml.rb All calls to 'exit!' and 'exit' replaced with a unique 'exit #' NOTE SMALL BEHAVIOR CHANGE: 'exit' alone returned 0, now returns # ml Return unique exit code from deploy/lib/ml.rb instead of generalizing to 1 when an error is encountered For more information reference issue marklogic-community#543: marklogic-community#543
Overview of the Issue
Example:
--- VS: ---
NOTES:
Motivation for or Use Case
Roxy Version
Ruby Version
Operating System
Suggest a Fix
UPDATE 2:
Pull Request: #546
UPDATE 1:
ORIGINAL TEXT:
UPDATE: Help behaves as expected because it returns using "exit" instead of "exit!"
Help.doHelp(@logger, command)
Help.doHelp(@logger, :usage, "Unknown command #{command}!")
raise HelpException.new(command, "Missing environment for #{command}") if @properties["environment"].nil?
The text was updated successfully, but these errors were encountered: