php worker进程,worker进程不断被重启

使用官网推荐的swoole-yaf框架,启动服务后 发现worker进程在不断重启,worker启动后会自动执行默认的controller action。master和manager 是稳定的{{{

class HttpServer

{

public static $instance;

public $http;

public static $get;

public static $post;

public static $header;

public static $server;

private $application;

public $processName = 'HttpServer';

public function __construct() {

$http = new swoole_http_server("172.30.102.41", 9501);

$http->set(

array(

'worker_num' => 4,

'daemonize' => false,

'max_request' => 1000,

'dispatch_mode' => 1

)

);

$http->on('Start', array($this, 'onMasterStart'));

$http->on('ManagerStart', array($this, 'onManagerStart'));

$http->on('WorkerStart' , array( $this , 'onWorkerStart'));

$http->on('request', function ($request, $response) {

if( isset($request->server) ) {

HttpServer::$server = $request->server;

}else{

HttpServer::$server = [];

}

if( isset($request->header) ) {

HttpServer::$header = $request->header;

}else{

HttpServer::$header = [];

}

if( isset($request->get) ) {

HttpServer::$get = $request->get;

}else{

HttpServer::$get = [];

}

if( isset($request->post) ) {

HttpServer::$post = $request->post;

}else{

HttpServer::$post = [];

}

ob_start();

try {

$yaf_request = new Yaf_Request_Http(

HttpServer::$server['request_uri']);

$this->application

->getDispatcher()->dispatch($yaf_request);

} catch ( Yaf_Exception $e ) {

var_dump( $e );

}

$result = ob_get_contents();

ob_end_clean();

$response->end($result);

});

$http->setGlobal(HTTP_GLOBAL_ALL);

$http->start();

}

public function onMasterStart($server) {

swoole_set_process_name($this->processName.' master process');

}

public function onWorkerStart($server, $workerId) {

swoole_set_process_name($this->processName.' worker process');

define('APPLICATION_PATH', dirname(__DIR__));

$this->application = new Yaf_Application( APPLICATION_PATH .

"/conf/application.ini");

ob_start();

try {

$this->application->bootstrap()->run();

} catch(Yaf_Exception $e) {

var_dump($e);

}

ob_end_clean();

}

public function onManagerStart($server) {

swoole_set_process_name($this->processName.' manager process');

}

public static function getInstance() {

if (!self::$instance) {

self::$instance = new HttpServer;

}

return self::$instance;

}

}

HttpServer::getInstance();

}}}

{{{

[vagrant@localhost ~]$ ps uax | grep HttpServer

vagrant 12430 0.2 2.3 445548 23988 pts/2 Sl+ 07:46 0:00 HttpServer master process

vagrant 12431 2.7 0.6 369360 6296 pts/2 S+ 07:46 0:00 HttpServer manager process

vagrant 13378 0.0 0.6 187024 6872 pts/2 R+ 07:46 0:00 HttpServer worker process

vagrant 13379 0.0 0.7 253348 7236 pts/2 R+ 07:46 0:00 HttpServer worker process

vagrant 13380 0.0 0.7 365720 7348 pts/2 D+ 07:46 0:00 HttpServer worker process

vagrant 13382 0.0 0.0 103320 908 pts/1 S+ 07:46 0:00 grep HttpServer

[vagrant@localhost ~]$ ps uax | grep HttpServer

vagrant 12430 0.2 2.3 445548 23988 pts/2 Sl+ 07:46 0:00 HttpServer master process

vagrant 12431 2.6 0.6 369360 6296 pts/2 S+ 07:46 0:00 HttpServer manager process

vagrant 13477 0.0 0.7 356884 7864 pts/2 R+ 07:46 0:00 HttpServer worker process

vagrant 13478 0.0 0.7 365720 7348 pts/2 D+ 07:46 0:00 HttpServer worker process

vagrant 13479 0.0 0.7 365720 7280 pts/2 D+ 07:46 0:00 HttpServer worker process

vagrant 13480 0.0 0.7 365720 7236 pts/2 D+ 07:46 0:00 HttpServer worker process

vagrant 13482 0.0 0.0 103320 908 pts/1 S+ 07:46 0:00 grep HttpServer

}}}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值