Download the PHP package laravel-addons/command-daemonizer without Composer
On this page you can find all versions of the php package laravel-addons/command-daemonizer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download laravel-addons/command-daemonizer
More information about laravel-addons/command-daemonizer
Files in laravel-addons/command-daemonizer
Package command-daemonizer
Short Description Laravel/Lumen console command daemonizer with graceful shutdown
License MIT
Homepage https://github.com/laravel-addons/command-daemonizer
Informations about the package command-daemonizer
Laravel Command Daemonizer
Run a Laravel console command as a long-lived process with gracefully shutdown.
Installation
Laravel will automatically add the service provider CommandDaemonizerServiceProvider
to the file config/app.php
in providers
option.
In Lumen, you MUST manually register the service provider CommandDaemonizerServiceProvider
in bootstrap/app.php
file:
How to use
For example, run kafka consumer
- You MUST implement method
daemon()
. This method will run in an endless loop. - You can use constructor to inject your dependency or inject dependency in
daemon()
method. Your dependencies will be resolved. - You can override the empty parent method
init()
to run some code before starting the daemon.
Options
DaemonCommand
append some options to you command:
Gracefully shutdown
Since daemonized commands are long-lived processes, they will not pick up changes to your code without being restarted. So, the simplest way to deploy an application using daemonized commands is to restart the commands during your deployment process. You may gracefully restart all of the daemonized commands by issuing the daemon-command:restart
:
This command will instruct all daemonized commands to gracefully "die" after they finish processing their current step in loop. Since the daemonized commands will die when the daemon-command:restart
command is executed, you should be running a process manager such as Supervisor to automatically restart the daemonized commands.
This library uses the cache to store restart signals, so you should verify a cache driver is properly configured for your application before using this feature.
Based on Illuminate Queue Worker.
All versions of command-daemonizer with dependencies
illuminate/console Version ^5.0|^6.0|^7.0
illuminate/support Version ^5.0|^6.0|^7.0