Skip to content
This repository has been archived by the owner on Oct 24, 2019. It is now read-only.

Fixing compatibility and getting rid of warnings #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions bin/swoole.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@

//php swoole.php testserver start


$name = $argv[1];
$cmd = $argv[2]; //cmd name
$name = isset($argv[1]) ? $argv[1] : null;
$cmd = isset($argv[2]) ? $argv[2] : null; //cmd name
$cmd = empty($cmd) ? $name : $cmd;
$RunningServer = array();
//需要cmd 和 name name 支持 all 和 具体的serverName
Expand Down Expand Up @@ -194,13 +193,8 @@ function StartServSock($RunServer)
'worker_num' => 1,
'daemonize' => true
));
$serv->on('WorkerStart', function ($serv, $workerId) {
//监控周期
$serv->addtimer(1000);

});
//定时器中操作 主要为轮巡 启动服务
$serv->on('Timer', function ($serv, $interval) {

$tick_check = function ($serv, $interval) {
StartLogTimer(__LINE__ . 'timer start ' . time());
if (empty($serv->runServer)) {
StartLogTimer(__LINE__ . ' ' . 'no server is running ' . PHP_EOL);
Expand All @@ -218,7 +212,21 @@ function StartServSock($RunServer)
StartLogTimer(__LINE__ . date('Y-m-d H:i:s') . ' ' . print_r($serverName, true) . ' server is running success' . PHP_EOL);
}
}
};

$serv->on('WorkerStart', function ($serv, $workerId) {
//监控周期
if (!$serv->taskworker) {
$serv->tick(1000, $tick_check);
}
else
{
$serv->addtimer(1000);
}
});

//定时器中操作 主要为轮巡 启动服务
$serv->on('Timer', $tick_check);

$serv->on('connect', function ($serv, $fd, $from_id) {
echo "[#" . posix_getpid() . "]\tClient@[$fd:$from_id]: Connect.\n";
Expand Down