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

Add exit codes to status command #1191

Merged
merged 2 commits into from
Sep 26, 2022

Conversation

mbardelmeijer
Copy link
Contributor

@mbardelmeijer mbardelmeijer commented Sep 26, 2022

This PR adds exit codes to the horizon:status artisan command.

The use-case for this is to monitor the Horizon status via monitoring tools, which we run on top of the normal supervisor configuration.

We've noticed in production usage that supervisor didn't restart the Horizon worker in a specific edge-case where Redis crashed. The status command however gave the correct status of inactive. We wish to monitor the horizon:status output to ensure the queue is always running.

Our current workaround is checking the output string, but we would prefer to use exit code checking.

I was unsure which exit code to assign to the paused status. I've landed on exit code 1. Happy to receive input on that.

This PR also adds colored output to the status:

  • error for inactive (red) - exit code 1
  • warn for paused (orange) - exit code 1
  • info for running (green) - exit code 0

@taylorotwell taylorotwell merged commit de84bf8 into laravel:5.x Sep 26, 2022
@PHLAK
Copy link

PHLAK commented Oct 3, 2022

@mbardelmeijer I know this has already been merged but I was wondering what your reasoning was for using an exit code of 1 for warn/paused instead of a different code (e.g. 2)? I would think a different exit code would be useful for determining the difference between inactive and paused while still being able to do a "not equal to 0" check for checking if horizon was not running regardless of condition.

I don't have an immediate use for this or anything but was curious if this could be improved.

@mbardelmeijer
Copy link
Contributor Author

@PHLAK sure! I was unsure what exit code exactly to use there too.

I argued that exit code 2 is mostly used for a more severe error in bash scripts (generally). As the status is paused, I would argue that exit code 1 would still be the best fit. Happy to revisit though.

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.

3 participants