Download the PHP package mvdstam/graceful-laravel-workers without Composer

On this page you can find all versions of the php package mvdstam/graceful-laravel-workers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package graceful-laravel-workers

Graceful Laravel Workers

Stopping your Workers and Jobs without hurting your application.

In many modern webapplications, many tasks are handled asynchronously through the use of some kind of queueing system and jobs. In Laravel and Lumen-based applications, this is possible through the use of the illuminate/queue component. This package expands a little bit upon that component by making it possible to gracefully stop Workers (or any kind of process for that matter) through the use of Posix Signals. This also enables your queue workers to be run inside of Docker containers and be stopped in a graceful and clean way, since Docker utilizes posix signals to stop running containers when, for example, updating them.

Finally, gracefully cleaning up running processes is a crucial part of any 12-factor application.

Why is this important?

When a queue worker is started through php artisan queue:work --daemon, a long-running PHP process is started. This process will run endlessly until it is stopped by either external sources (posix signals) or internal sources (the process crashes or simply stops because of an exit;).

Usually, these PHP processes are stopped externally by sending SIGTERM or SIGINT signals to the underlying processes. The default behaviour of PHP is to stop the process immediately, which means that any kind of important process is interrupted and possibly your data is lost. By trapping these signals with the use of the PCNTL extension, we can catch these signals and define custom behaviour when this happens. This is especially interesting when running queue workers within Docker containers, since containers are ephemeral by design and can (should) be replaced at any time.

shutting_down()

The most important aspect of this package is the function shutting_down(). In your long-running jobs, simply call shutting_down() in each iteration. This function returns TRUE when a signal has been caught and your application should prepare to shut down immediately. For example:

Version compatibility

This package is compatible with Lumen/Laravel 5.1 (LTS) and Lumen/Laravel 5.2. Version 5.3 is not supported at the time of writing.

Requirements

Install

Via composer

Add the GracefulLaravelWorkersServiceProvider to your app.php:

In order for the package to be correctly initialized, please make sure to add the GracefulLaravelWorkersServiceProvider after the Illuminate\Queue\QueueServiceProvider.

Finally, run php artisan vendor:publish.

Usage

Start your worker with php artisan queue:work --daemon and try sending SIGINT or SIGTERM signals to that process when it picks up a job. When the process is in the foreground, simply press ctrl+c to send a SIGINT.

Gotchas


All versions of graceful-laravel-workers with dependencies

PHP Build Version
Package Version
Requires ext-pcntl Version *
php Version >=5.6.0
illuminate/queue Version >=5.0 <5.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mvdstam/graceful-laravel-workers contains the following files

Loading the files please wait ....