2017 © Pedro Peláez
 

library parallel-prefork

A simple prefork server framework

image

travail/parallel-prefork

A simple prefork server framework

  • Wednesday, August 30, 2017
  • by travail
  • Repository
  • 4 Watchers
  • 37 Stars
  • 42,620 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 8 Forks
  • 1 Open issues
  • 6 Versions
  • 3 % Grown

The README.md

Parallel\Prefork

NAME

Parallel\Prefork - A simple prefork server framework, (*1)

SYNOPSIS

<?php
use \Parallel\Prefork;

require_once '/path/to/vendor/autoload.php';

$pp = new Prefork([
    'max_workers'  => 5,
    'trap_signals' => [
        SIGHUP  => SIGTERM,
        SIGTERM => SIGTERM,
    ],
]);

while ($pp->signalReceived() !== SIGTERM) {
    if ($pp->start()) {
        continue;
    }

    // ... do some work within the child process ...

    $pp->finish();
}

$pp->waitAllChildren();

INSTALLATION

To install this package into your project via composer, add the following snippet to your composer.json. Then run composer install., (*2)

"require": {
    "travail/parallel-prefork": "dev-master"
}

If you want to install from github, add the following:, (*3)

"repositories": [
    {
        "type": "vcs",
        "url": "git@github.com:travail/php-Parallel-Prefork.git"
    }
]

DESCRIPTION

Parallel\Prefork supports graceful shutdown and run-time reconfiguration., (*4)

DEPENDENCIES

  • posix
  • pcntl

METHODS

__construct

Parallel\Prefork __construct([
    'max_workers'          => int $max_workers,
    'err_respawn_interval' => int $err_respawn_interval,
    'trap_signals'         => [int $signal_trapped_in_parent_process => int $signal_sent_to_child_processes],
])

Instantiation. Takes an array as an argument. Recognized parameters are as follows., (*5)

max_workers

Number of worker processes (default: 3), (*6)

trap_signals

Array of signals to be trapped. Manager process will trap the signals listed in the keys of the array, and send the signal specified in the associated value (if any) to all worker processes., (*7)

err_respawn_interval

Number of seconds to deter spawning of child processes after a worker exits abnormally (default: 1), (*8)

start

bool start()

The main routine. Returns undef in child processes. Returns a true within manager process upon receiving a signal specified in the trapSignals array., (*9)

finish

void finish(int $exit_code)

Child processes should call this function for termination. Takes exit code as an optional argument. Only usable from child processes., (*10)

signalAllChildren

void signalAllChildren(int $signal)

Sends signal to all worker processes. Only usable from manager process., (*11)

waitAllChildren

void waitAllChildren()

Blocks until all worker processes exit. Only usable from manager process., (*12)

signalReceived

int signalReceived()

Returns a signal manager process trapped., (*13)

THANKS TO

Kazuho Oku, (*14)

AUTHOR

travail, (*15)

LICENSE

This library is free software. You can redistribute it and/or modify it under the same terms as PHP itself., (*16)

The Versions

30/08 2017

dev-master

9999999-dev

A simple prefork server framework

  Sources   Download

PHP-3.0

The Requires

  • php >=5.3
  • ext-posix *
  • ext-pcntl *

 

The Development Requires

30/08 2017

v0.2.1

0.2.1.0

A simple prefork server framework

  Sources   Download

PHP-3.0

The Requires

  • php >=5.3
  • ext-posix *
  • ext-pcntl *

 

The Development Requires

30/08 2017

dev-develop

dev-develop

A simple prefork server framework

  Sources   Download

PHP-3.0

The Requires

  • php >=5.3
  • ext-posix *
  • ext-pcntl *

 

The Development Requires

23/08 2017

v0.2.0

0.2.0.0

A simple prefork server framework

  Sources   Download

PHP-3.0

The Requires

  • php >=5.3
  • ext-posix *
  • ext-pcntl *

 

The Development Requires

23/08 2017

v0.2.0-BETA

0.2.0.0-beta

A simple prefork server framework

  Sources   Download

PHP-3.0

The Requires

  • php >=5.3
  • ext-posix *
  • ext-pcntl *

 

The Development Requires

01/05 2014

v0.1.0

0.1.0.0

A simple prefork server framework

  Sources   Download

PHP-3.0

The Requires

  • php >=5.3
  • ext-posix *
  • ext-pcntl *

 

The Development Requires