Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/toflar/cronjob-supervisor
Some kind of supervisor helper when you only have cronjobs available
https://github.com/toflar/cronjob-supervisor
Last synced: 18 days ago
JSON representation
Some kind of supervisor helper when you only have cronjobs available
- Host: GitHub
- URL: https://github.com/toflar/cronjob-supervisor
- Owner: Toflar
- Created: 2023-07-26T17:42:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-24T07:02:14.000Z (7 months ago)
- Last Synced: 2024-05-01T13:56:54.054Z (7 months ago)
- Language: PHP
- Size: 19.5 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# Cronjob Supervisor
Need to have a number of workers on some server but have no access to any daemon like `supervisord` or the likes but
can configure a minutely cronjob? This library might come in handy for you then.1. Installation
`composer require toflar/cronjob-supervisor`
2. Create your `runner.php`:
```php
withCommand(new BasicCommand('sleep 10', 2, function () {
return new Process(['sleep', '10']);
}))
->withCommand(new BasicCommand('sleep 29', 4, function () {
return new Process(['sleep', '29']);
}))
->supervise()
;
```3. Configure the minutely cronjob
`* * * * * /path/to/your/php/binary/php runner.php`
That's it. The `Supervisor` will take care that even if your jobs are still running after a minute has passed, only
ever your maximum number of processes will be created.For this to work, it uses multiple providers to check if processes are still running. Currently supported are:
* `posix_getpgid()`
* `ps -p `
* `tasklist /FI PID eq `Which means you should be able to run it on most Linux and Windows combinations.