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

verdi daemon status should return non-zero exit code, if daemon is not running #3728

Closed
ltalirz opened this issue Jan 24, 2020 · 7 comments · Fixed by #3729
Closed

verdi daemon status should return non-zero exit code, if daemon is not running #3728

ltalirz opened this issue Jan 24, 2020 · 7 comments · Fixed by #3729
Assignees

Comments

@ltalirz
Copy link
Member

ltalirz commented Jan 24, 2020

currently, it always returns exit code 0.

@ConradJohnston
Copy link
Contributor

In the spirit of exit codes, isn't it already doing the correct thing?
The command verdi daemon status is successful and so returns 0.
That the daemon isn't running isn't ideal, but I think this would be the wrong way to check for it a shell script.

@ltalirz
Copy link
Member Author

ltalirz commented Feb 10, 2020

I also wondered about this when I made the change, but I think what I'm suggesting here is actually the default behavior on unix systems.

E.g. for systemd services, calling sudo service apache2 status will return a non-zero exit status if apache2 is not running (otherwise 0).

In practical terms, I also think this makes the exit code more useful.

@greschd
Copy link
Member

greschd commented Feb 10, 2020

Just checked the same for postgresql:

a-dogres@A-DOGRES-082219:/mnt/c/Users/a-dogres$ service postgresql status
10/main (port 5432): down
a-dogres@A-DOGRES-082219:/mnt/c/Users/a-dogres$ echo $?
3

Found this guide on exit code numbers, and I think it should not be 1, though: http://www.tldp.org/LDP/abs/html/exitcodes.html

@ltalirz
Copy link
Member Author

ltalirz commented Feb 10, 2020

Right, also for systemd it was 3.
Happy to make it 3 if people prefer

@greschd
Copy link
Member

greschd commented Feb 10, 2020

Yeah, that might've just been systemd's choice for postgresql on my machine. I'm not an expert on unix conventions by any means, but at least from looking at that description 3 would be a better choice.

@greschd
Copy link
Member

greschd commented Feb 10, 2020

That convention doesn't appear too strong though, with a tiny bit of poking around I haven't managed to get anything but 1 exit codes from the GNU coreutils 😄

@ConradJohnston
Copy link
Contributor

Ha, I'm convinced. I do agree it would be more useful, assuming it's well doc'd. There's a need to differentiate what happens if verdi fails though, vs. where verdi is successful, but the daemon is down.

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

Successfully merging a pull request may close this issue.

4 participants