Coder Social home page Coder Social logo

nikkobautista / php-resque-pool Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shonm/php-resque-pool

0.0 2.0 0.0 152 KB

This project is slated to be superseded by Sonido\Warden

Home Page: https://github.com/Sonido/Warden

License: MIT License

php-resque-pool's Introduction

PHP Resque Pool

Php resque pool is a port of resque-pool for managing php-resque workers. Given a config file, it manages your workers for you, starting up the appropriate number of workers for each worker type.

Benefits

  • Less config - With a simple YAML file, you can start up a pool daemon.
  • Monitoring - If a worker dies for some reason, php-resque-pool will start another.
  • Easily change worker distribution - To change your worker counts just update the YAML file and send the manager a HUP signal.

How to use

YAML file config

Create a config/resque-pool.yml (or resque-pool.yml) with your worker counts. The YAML file supports both using root level defaults as well as environment specific overrides (RESQUE_ENV environment variables can be used to determine environment). For example in config/resque-pool.yml:

foo: 1
bar: 2
"foo,bar,baz": 1

production:
  "foo,bar,baz": 4

Start the pool manager

Then you can start the queues via:

bin/resque-pool --daemon --environment production

This will start up seven worker processes, one exclusively for the foo queue, two exclusively for the bar queue, and four workers looking at all queues in priority. With the config above, this is similar to if you ran the following:

QUEUES=foo php resque.php
QUEUES=bar php resque.php
QUEUES=bar php resque.php
QUEUES=foo,bar,baz php resque.php
QUEUES=foo,bar,baz php resque.php
QUEUES=foo,bar,baz php resque.php
QUEUES=foo,bar,baz php resque.php

The pool manager will stay around monitoring the resque worker parents, giving three levels: a single pool manager, many worker parents, and one worker child per worker (when the actual job is being processed). For example, ps -ef f | grep [r]esque (in Linux) might return something like the following:

resque    13858     1  0 13:44 ?        S      0:02 resque-pool-manager: managing [13867, 13875, 13871, 13872, 13868, 13870, 13876]
resque    13867 13858  0 13:44 ?        S      0:00  \_ resque-1.0: Waiting for foo
resque    13868 13858  0 13:44 ?        S      0:00  \_ resque-1.0: Waiting for bar
resque    13870 13858  0 13:44 ?        S      0:00  \_ resque-1.0: Waiting for bar
resque    13871 13858  0 13:44 ?        S      0:00  \_ resque-1.0: Waiting for foo,bar,baz
resque    13872 13858  0 13:44 ?        S      0:00  \_ resque-1.0: Forked 7481 at 1280343254
resque     7481 13872  0 14:54 ?        S      0:00      \_ resque-1.0: Processing foo since 1280343254
resque    13875 13858  0 13:44 ?        S      0:00  \_ resque-1.0: Waiting for foo,bar,baz
resque    13876 13858  0 13:44 ?        S      0:00  \_ resque-1.0: Forked 7485 at 1280343255
resque     7485 13876  0 14:54 ?        S      0:00      \_ resque-1.0: Processing bar since 1280343254

You can get similar output with pstree, or on some systems with ps auxd | grep [r]esque

Running as a daemon will currently output to stdout, although this will be configurable in the future.

SIGNALS

The pool manager responds to the following signals:

  • HUP - reload the config file, restart all workers.
  • QUIT - gracefully shut down workers (via QUIT) and shutdown the manager after all workers are done.
  • INT - gracefully shut down workers (via QUIT) and immediately shutdown manager
  • TERM - immediately shut down workers (via INT) and immediately shutdown manager (configurable via command line options)
  • WINCH - (only when running as a daemon) send QUIT to each worker, but keep manager running (send HUP to reload config and restart workers)
  • USR1/USR2/CONT - pass the signal on to all worker parents (see Resque docs).

Use HUP to change the number of workers per worker type. Signals can be sent via the kill command, e.g. kill -HUP $master_pid

Other Features

You can specify an alternate config file by setting the RESQUE_POOL_CONFIG or with the --config command line option.

Contributors

  • Your name here!

php-resque-pool's People

Contributors

ebernhardson avatar shonm avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.