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

horizon:purge kills processes of another Laravel application on the same server #769

Closed
rafalglowacz opened this issue Feb 18, 2020 · 6 comments

Comments

@rafalglowacz
Copy link

  • Horizon Version: v3.2.5
  • Laravel Version: 5.8.28
  • PHP Version: 7.2.21
  • Redis Driver & Version: phpredis
  • Database Driver & Version: MySQL 5.7.27

Description:

We have Horizon running for a few different Laravel installations on the same server. A while ago we noticed some orphaned workers, so we've added horizon:purge to scheduled tasks. But as it turns out this kills all processes except for the ones monitored by the current instance. Including all masters, supervisors and workers running for the other Laravel apps.

Apparently this is caused by the ProcessInspector class. In its current method it gathers all running processes that simply have "horizon" in their name (and don't have "purge" in the name).

I'll fix that locally by filtering the processes by supervisor name, as our supervisors use the application name to differentiate themselves. Not sure what can be done in Horizon as a whole, I'll try to look into that later.

@themsaid
Copy link
Member

So you have multiple applications running horizon on the same server, and each application is using a different redis connection? is that what you have?

@rafalglowacz
Copy link
Author

Yes, they all use different connections, so there's no problems with conflicts between them. Only the purge command seems incompatible with multiple applications on the same server.

@driesvints
Copy link
Member

It's indeed true that it'll stop all horizon processes, even from other apps. But given that those processes will automatically restart by your daemons that isn't an issue. We'll add a note about this in the docs. Thanks for reporting.

@rafalglowacz
Copy link
Author

Why has this been closed? Has anything been done to resolve it yet? It's clear that this is not what horizon:purge was intended to do. Its description is "Terminate any rogue Horizon processes". Its code tries to retrieve known processes and only kill unknown ones. But someone forgot that there might be other Laravel apps running. It's an easy mistake to make, but it's still a bug.

The documentation says that "you should configure a process monitor to monitor the php artisan horizon command and restart it if it quits unexpectedly". Not that "you have to configure a process monitor because Horizon will kill its own processes from time to time".

If this won't be fixed then horizon:purge should be changed to just kill all horizon processes so that the mandatory supervisor can start everything from scratch. Pretending that it kills just orphaned processes means hours if not days of debugging why a process stops without any errors logged.

@themsaid
Copy link
Member

themsaid commented Feb 19, 2020

@rafalglowacz feel free to open a PR with a proposed solution to get around this limitation. Purge is going to kill rogue processes and some normal processes, if you find a way to change this behaviour and make it identify only rogue processes then it's a good enhancement.

@Aurelien-NGT-11
Copy link
Contributor

Hi,

Have you already seen some orphans processes with Horizon @themsaid ?
If yes, do you have any idea how I could reproduce this ?
Because this could be solved by killing only monitored processes.

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

No branches or pull requests

4 participants