Download the PHP package resgen/lumen-proc without Composer
On this page you can find all versions of the php package resgen/lumen-proc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package lumen-proc
Lumen Process Control Drivers
Process control for running artisan commands as a deamon. Respects all sigterm commands sent. Includes TTL driver and RunOnce drivers. This should work for Laravel too, but its only been tested with lumen.
Why?
When running artisan commands as a background deamon process, the ProcessControl will ensure that SIGTERMs are respected. This is especially important when running artisan commands as the docker entrypoint. It will respect docker's kill signal and give you a chance to finish work before exiting.
Install
With composer:
Ensure pcntl_async_signals is enabled for your php install. Example docker alpine RUN:
Configuration
Add the laravel service provider Resgen\Common\Proc\ProcessControlProvider
to your app.
Then add the following ENV var with the selected driver:
By default, the TTL drivers will log an INFO heart beat every ~5 seconds. You can also disable the heart beat log by doing:
You may enable SignalException
to be thrown asynchronously when a signal is processed, this will happen from wherever your normal code is being executed and gives you a chance to clean things up
gracefully while still responding immediately to signals (or ignore them if appropriate.)
Available Drivers
TtlProcessDriver
ENV name: ttl
.
Runs for N number of seconds. Defaults to 300s runtime. Logs a heart beat message every ~6 seconds. You can adjust the runtime by setting the LUMEN_PROC_TTL=1000s
. Will exit if a SIGTERM is sent.
Intended to be used with a process supervisor like runit, supervisord or inside a docker orchestration env like kubernetes.
TtlInstantKillProcessDriver
ENV name: ttl_hardexit
.
Same as TtlProcessDriver, but throws exception as soon as signal is recieved.
KeepAliveProcessDriver
ENV name: keepalive
.
Runs until a SIGTERM signal is sent. Not recommended for production usage. Processes should cycle.
RunOnceProcessDriver
ENV name: runonce
.
Will escape immediately when check()
is called.
Example Usage
Cron Calls
LoopingCommand
automatically enables internal cron calls of functions to occur at regular intervals. This check happens each time loop()
returns control or while the command is sleeping.