Stark

WBOY
Libérer: 2016-06-20 12:52:51
original
1032 Les gens l'ont consulté

Stark

Starkis a library for running php code as multi-process daemon.

Requires

  • PHP 5.3 or Higher
  • A POSIX compatible operating system (Linux, OSX, BSD)
  • POSIX and PCNTL Extensions for PHP

Features

  • Simple Callbacks
  • Daemon Monitoring
  • Automatic Restart

Usage

We just need only one script file and one config file. The php script file defines the callback functions. The ini config file defines daemon's enviroments. You can use this command to start you daemon:

php src/Stark/run.php -f [ini_config_file]
Copier après la connexion

Daemon configuration

  • main.name : A string specifying the daemon's unique name
  • main.host : A string specifying the bind ip address of monitoring server
  • main.port : An integer value specifying the bind port of monitoring server.
  • main.working_dir : A path to a directory where the daemon should put its log file and socket file.
  • run.script_file : The file that defines the callback funtions.
  • run.memory_limit : Specified as the php shorthand notation for bytes (see the manual ). This will be set asmemory_limitviaini_set
  • worker.count : An integer value specifying the number of worker.
  • worker.max_run_count : The maximum number of runs, after the number reached the worker will restart every time.
  • worker.max_run_seconds : An integer value in seconds, specifying the maximum time the worker will restart after the time arrives.
  • worker.max_idle_seconds : An integer value in seconds, specifying the longest idle time, the worker will restart after the time arrives.

An example configuration ini file:

[main]name = "config_1"host = "127.0.0.1"port = 9003working_dir = "/tmp"[run]script_file = "run_1.php"memory_limit = "1024M"[worker]count = 3max_run_count = 10000max_run_seconds = 3600max_idle_seconds = 60
Copier après la connexion

An example callback file:
<?php$g_count = 0;function run($worker, $data) {    global $g_count;    $g_count++;    echo "Worker {$worker->index} current: {$g_count}\r\n";    usleep(100000);}
Copier après la connexion

项目主页:http://www.open-open.com/lib/view/home/1436863173271

source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!