Stark
Jun 20, 2016 pm 12:52 PM
Stark
An example callback file:
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]
登入後複製
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
登入後複製
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);}
登入後複製
项目主页:http://www.open-open.com/lib/view/home/1436863173271
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱門文章
擊敗分裂小說需要多長時間?
3 週前
By DDD
倉庫:如何復興隊友
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
1 週前
By 尊渡假赌尊渡假赌尊渡假赌
公眾號網頁更新緩存難題:如何避免版本更新後舊緩存影響用戶體驗?
3 週前
By 王林

熱門文章
擊敗分裂小說需要多長時間?
3 週前
By DDD
倉庫:如何復興隊友
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
1 週前
By 尊渡假赌尊渡假赌尊渡假赌
公眾號網頁更新緩存難題:如何避免版本更新後舊緩存影響用戶體驗?
3 週前
By 王林

熱門文章標籤

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)