Download the PHP package p3k/caterpillar without Composer

On this page you can find all versions of the php package p3k/caterpillar. 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 caterpillar

Caterpillar

Caterpillar is a queuing mechanism based on beanstalkd. It handles enqueuing and processing tasks, and managing multiple concurrent workers that can process the same queue.

You can use Caterpillar to quickly parallelize background tasks simply by running many workers.

Installation

Download from source or use Composer.

git clone [email protected]:aaronpk/caterpillar.git

Add this to your composer.json file in the "require" section:

"p3k/caterpillar": "0.1.*"

Usage

The working example in the example folder is explained in more detail below.

Queuing Tasks

To queue a task, first create a new Caterpillar object and pass in the beanstalkd tube name you want to use, as well as the beanstalkd server and a path to write log files.

You can queue any static method of any class to run. For illustration purposes, we'll use this test task below. All it does is says it's running, waits a random amount of time, and then finishes.

Now we'll queue up 10 tasks and each one is identified by a random number just so they show up better in the logs.

Running Workers

To run the workers, create a script that will run the run_workers command on the Caterpillar class. You'll first need to make a Caterpillar object the same way you did to queue jobs to set up its config. Then just run the run_workers method with the number of concurrent processes you want to run as the first argument. The script will fork this many children and they will all run in parallel, managed by the parent process.

When you run this from the console, the parent process stays in the foreground. You can quit all the workers by pressing CTRL+C and waiting a couple seconds for them to finish.

If you want to run the parent process in the background, such as when using some system init methods, you can pass true as the second argument, e.g. $c->run_workers(2, true).

Running as a System Service

For production use, you'll likely want to run the workers as a system service so that they start when the server boots, and continue running automatically. How you do this will depend on the particular operating system you're using. You'll need to configure a system-level startup script to run your worker file that we described above.

systemd

For Ubuntu using systemd, you can create an init script like the below, and save as /etc/init/yourservice.conf

supervisord

Using supervisord, you can create a config file like the below, and save as /etc/supervisor/conf.d/yourservice.conf

API Documentation

new Caterpillar($tube, $server, $port, $log_path)

Creates the Caterpillar object and configures it to use a specific tube, beanstalkd server and log path.

queue($class, $method, $args, $opts)

Enqueues a new job onto the tube.

run_workers($num, $background)

Runs the number of workers specified as separate child processes.

print_stats()

Outputs info about the number of jobs ready, delayed, buried, and the number of processes watching beanstalkd tubes.

Sample output:

See the beanstalkd documentation for more details on what each of these mean.

TODO

License

Copyright 2015-2017 by Aaron Parecki

Available under the Apache 2.0 License. See LICENSE.txt


All versions of caterpillar with dependencies

PHP Build Version
Package Version
Requires php Version >5.4.0
pda/pheanstalk Version 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 p3k/caterpillar contains the following files

Loading the files please wait ....