forked from v2board/v2board
-
Notifications
You must be signed in to change notification settings - Fork 231
/
webman.php
executable file
·40 lines (31 loc) · 992 Bytes
/
webman.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Adapterman\Adapterman;
use Workerman\Worker;
use Illuminate\Support\Facades\Cache;
putenv('APP_RUNNING_IN_CONSOLE=false');
define('MAX_REQUEST', 6600);
define('isWEBMAN', true);
Adapterman::init();
$ncpu = substr_count((string)@file_get_contents('/proc/cpuinfo'), "\nprocessor")+1;
$http_worker = new Worker('http://127.0.0.1:6600');
$http_worker->count = $ncpu * 2;
$http_worker->name = 'AdapterMan';
$http_worker->onWorkerStart = static function () {
//init();
require __DIR__.'/start.php';
};
$http_worker->onMessage = static function ($connection, $request) {
static $request_count = 0;
static $pid;
if ($request_count == 1) {
$pid = posix_getppid();
Cache::forget("WEBMANPID");
Cache::forever("WEBMANPID", $pid);
}
$connection->send(run());
if (++$request_count > MAX_REQUEST) {
Worker::stopAll();
}
};
Worker::runAll();