Horizon: Shell live check if horizon is running

Created on 14 Jan 2019  Â·  9Comments  Â·  Source: laravel/horizon

Hello,

It is possible to check if horizon is running by running a command in a shell?
I need this feature to implement a readinessProbe and livenessProbe on Kubernetes.

Thanks for reply :)

enhancement

Most helpful comment

A new command for this was merged. Will be tagged soon.

All 9 comments

Using shell

You mean something like using ps?

Not sure how accurate this can be, but there's only one uber process controlling everything:

           |                   `-php(9575)-+-php7.2(9721)---php7.2(9908)
           |                               |-php7.2(9722)---php7.2(9912)
           |                               |-php7.2(9723)---php7.2(9917)
           |                               |-php7.2(9724)---php7.2(9918)
           |                               |-php7.2(9725)---php7.2(9907)
           |                               |-php7.2(9726)---php7.2(9915)
           |                               |-php7.2(9727)---php7.2(9909)
           |                               |-php7.2(9728)---php7.2(9910)
           |                               |-php7.2(9729)---php7.2(9911)
           |                               |-php7.2(9735)---php7.2(9906)
           |                               |-php7.2(9736)---php7.2(9914)
           |                               |-php7.2(9738)---php7.2(9916)
           |                               `-php7.2(9739)---php7.2(9913)

The one with 9575 looks like this:

$ ps auxw|grep 9575
vagrant   9575  0.0  0.8 360060 51864 ?        S    Jan13   1:20 php /vagrant/artisan horizon

So it would be possible to use something like:

$ ps auxw|grep 'artisan horizon$'
vagrant   9575  0.0  0.8 360060 51864 ?        S    Jan13   1:20 php /vagrant/artisan horizon

By inspecting Redis

Alternative you could also directly _look_ into redis, e.g.

127.0.0.1:6379[2]> ZRANGE horizon:masters 0 -1
1) "project-dev-xYjt"

gives you a list of currently running masters

Though I can understand the appeal to check the process table directly in a Pod?

I think it would be a good feature if we can 'ping' horizon worker or something like that

Makes sense to me!

The closest there's right now would be ./artisan horizon:supervisors but having a definite way to check if the "master" process is still running would be great.

@mfn could this be implemented in the library itself? Probably needs a dedicated endpoint?

At the moment I'm doing something hacky along the lines of :

ps -fe | egrep -q '[h]orizon:supervisor' || exit 1

which will tell you the process is running, but obviously not if it's actually working :-) Maybe even if the command could take an option of --plain or --csv then we could parse it a little easier with grep, eg :

horizon:supervisors --plain | egrep -q -v 'running' || exit 1

Just some background for anyone who doesn't use Docker/kubernetes etc - the healthchecks are quite important as they let the system know your container is actually up and running properly. It'll also use it to kill off a broken container and spin up a new one. They're also part of the dependency tree of your application - so you can have your 'app' which depends on 'horizon' which itself depends on 'redis' and 'mysql'. Docker/k8s will try and spin up the dependencies leading 'up' to the app and part of that is using healthchecks. If you don't have them then it starts the container and just assumes it's working - which can lead to some fairly tricky outcomes :-)

A new command for this was merged. Will be tagged soon.

Nice! Thx

On Fri, Mar 8, 2019, 11:44 Dries Vints notifications@github.com wrote:

Closed #468 https://github.com/laravel/horizon/issues/468.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/laravel/horizon/issues/468#event-2190263904, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AGikBDlL1OkDnVD2epCBA4Z3WLEYyiUUks5vUndpgaJpZM4Z9kUj
.

Wow - thank you! :-D A+++ package developer - would composer require again :-D

Thanks you so much all! you have helped us, thanks to this command you helped me and my team of eight students for their graduation project!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

etiennellipse picture etiennellipse  Â·  3Comments

RicardoRamirezR picture RicardoRamirezR  Â·  3Comments

mahdiahmadi73 picture mahdiahmadi73  Â·  3Comments

meathanjay picture meathanjay  Â·  3Comments

sojeda picture sojeda  Â·  5Comments