Download the PHP package mstrychalski/supervisor without Composer
On this page you can find all versions of the php package mstrychalski/supervisor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mstrychalski/supervisor
More information about mstrychalski/supervisor
Files in mstrychalski/supervisor
Package supervisor
Short Description :vertical_traffic_light: Process supervisor for PHP.
License MIT
Homepage https://github.com/mstrychalski/supervisor
Informations about the package supervisor
Supervisor
This library implements CLI process supervisors and aggregate supervisor supervisors in an attempt to limit damage done by failing scripts.
It can be installed in whichever way you prefer, but we recommend [Composer][packagist].
$ composer require graze/supervisor
Documentation
Assuming everything went well with the child process, the supervise
method
will stop watching the process and you can continue on your business. But what
happens to processes that fall flat on their face?
Now we've gone from one script failing to two scripts failing, but how does that help? Well, it doesn't, but that's where handlers come in.
Handlers
Handlers help you control what to do when a child process fails (and when they successfully terminate). You can do anything you like with the handlers:
- Retry the process
- Alert your developers or infrastructure team
- Requeue the job in some fancy queuing service
- Alert your error logging service
- Start a different script
- Stop other related scripts
- Simply throw an exception
Now if your process dies, the retry handler will restart it up to a maximim of 3 times. We can do even better than this though; suppose you want to retry 3 times then alert developers and log the error, all before throwing an exception. Just decorate!
This library currently only comes bundled with a few handlers, but by implementing a simple interface you can quickly use your own. Additional core handlers are always welcome!
Supervising the supervisors
So having a supervisor to watch your process is great, but what if you want to supervise multiple processes that are logically linked (ie. batch processing)? You can achieve this by supervising your individual process supervisors.
Just like the process supervisors, the supervisor supervisors handle successful and unsuccessful termination with handlers.
Who supervises the supervisor supervisor?
Depending on the complexity of logically grouped processes, you may need to have many tiers of failure management. This is entirely possible by passing supervisor supervisors into a parent supervisor supervisor. In fact, you can even mix the types of supervisors you supervise!
You can see how things could get crazy pretty quickly. This library, however, is by no means a replacement for true system daemon management. You should use something like systemd or upstart for that.
Contributing
We accept contributions to the source via Pull Request, but passing unit tests must be included before it will be considered for merge.
If you've found a bug, please include a failing test when you create an issue.
License
The content of this library is released under the MIT License by Nature Delivered Ltd..
You can find a copy of this license in LICENSE
or at http://opensource.org/licenses/mit.