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

Make use of command return codes #4

Closed
wants to merge 1 commit into from
Closed

Make use of command return codes #4

wants to merge 1 commit into from

Conversation

ecklm
Copy link

@ecklm ecklm commented Jun 5, 2020

The main command's return code might be an extremely valuable
information, therefore it needs to be returned when go-init exits. Pre
and post command exit codes may as well be valuable, therefore it is
also worth at least printing them.

In collaboration with: Dénes Fodor fodor.denes@balasys.hu

Resolves: #1


In case you want some examples:

# Non-zero exit code everywhere
$ ./go-init -pre "./exittest 5" -main "./exittest 3" -post "./exittest 7" ; echo $?
2020/06/05 14:31:10 [go-init] Pre-start command launched : ./exittest 5
2020/06/05 14:31:10 [go-init] Pre-start command exited with code 5
2020/06/05 14:31:10 [go-init] Main command launched : ./exittest 3
2020/06/05 14:31:10 [go-init] Main command exited with code 3
2020/06/05 14:31:10 [go-init] Post-stop command launched : ./exittest 7
2020/06/05 14:31:10 [go-init] Post-stop command exited with code 7
3

# Zero exit code in -main, non-zero elsewhere
$ ./go-init -pre "./exittest 5" -main "./exittest 0" -post "./exittest 7" ; echo $?
2020/06/05 14:31:15 [go-init] Pre-start command launched : ./exittest 5
2020/06/05 14:31:15 [go-init] Pre-start command exited with code 5
2020/06/05 14:31:15 [go-init] Main command launched : ./exittest 0
2020/06/05 14:31:15 [go-init] Main command exited with code 0
2020/06/05 14:31:15 [go-init] Post-stop command launched : ./exittest 7
2020/06/05 14:31:15 [go-init] Post-stop command exited with code 7
0

# Error in the command specification in -main
$ ./go-init -pre "./exittest 5" -main "exittest 3" -post "./exittest 7" ; echo $?
2020/06/05 14:31:00 [go-init] Pre-start command launched : ./exittest 5
2020/06/05 14:31:00 [go-init] Pre-start command exited with code 5
2020/06/05 14:31:00 [go-init] Main command launched : exittest 3
2020/06/05 14:31:00 [go-init] Main command exited with code -1
2020/06/05 14:31:00 [go-init] exec: "exittest": executable file not found in $PATH
2020/06/05 14:31:00 [go-init] Post-stop command launched : exittest 7
2020/06/05 14:31:00 [go-init] Post-stop command exited with code -1
2020/06/05 14:31:00 [go-init] exec: "exittest": executable file not found in $PATH
255

# Error in the command specification somewhere else
[ecklm@ecklm-balasys go-init ]$ ./go-init -pre "xyz" -main "./exittest 0" -post "./exittest 0" ; echo $?
2020/06/05 14:34:25 [go-init] Pre-start command launched : xyz
2020/06/05 14:34:25 [go-init] Pre-start command exited with code -1
2020/06/05 14:34:25 [go-init] exec: "xyz": executable file not found in $PATH
255

Where exittest has the following content:

#! /bin/bash

exit $1

The main command's return code might be an extremely valuable
information, therefore it needs to be returned when go-init exits. Pre
and post command exit codes may as well be valuable, therefore it is
also worth at least printing them.

In collaboration with: Dénes Fodor <fodor.denes@balasys.hu>
@ecklm
Copy link
Author

ecklm commented Jun 5, 2020

By the way, as this is a significant change in the interface, I'd suggest changing the version number to 0.1.0 in the CI.

@pablo-ruth
Copy link
Owner

Hi,
I'm sorry, as mentioned in the Readme, I don't maintain this project anymore. Please feel free to fork!

@pablo-ruth pablo-ruth closed this Nov 14, 2020
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

Successfully merging this pull request may close these issues.

Request: supress SIGTERM and SIGINT signals
2 participants