0

创建了一个进程 端口9501,创建了定时器间隔30分钟运行,

我9501端口都kill掉了,

他还在后台自己运行,怎么回事啊,

我写了个采集网页入库的,kill 9501端口。还是会入库

    public function __construct() {
        $this->serv = new swoole_server("0.0.0.0", 9501);
        $this->serv->set(array(
            'worker_num' => 2,
            'daemonize' => false,
            'max_request' => 10000,
            'dispatch_mode' => 2,
            'debug_mode'=> 1 ,
        ));

        $this->serv->on('WorkerStart', array($this, 'onWorkerStart'));
        $this->serv->on('Connect', array($this, 'onConnect'));
        $this->serv->on('Receive', array($this, 'onReceive'));
        $this->serv->on('Close', array($this, 'onClose'));
        // bind callback
        // $this->serv->on('Timer', array($this, 'onTimer'));
        $this->serv->start();


    }
    public function onWorkerStart( $serv , $worker_id) {
        // 在Worker进程开启时绑定定时器
        echo "onWorkerStart\n {$worker_id}";
        // 只有当worker_id为0时才添加定时器,避免重复添加
        if( $worker_id == 0 ) {

             swoole_timer_after(1000, function () {
                 return $this->caiji_start();
             });
 /*
             swoole_timer_tick($this->time, function () {
                 return $this->wenzhang();
             });*/



        }
    }
1 个回答
0

`swoole

Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 4.3.1
Built => Mar 28 2019 01:50:13
coroutine => enabled
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
http2 => enabled
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.display_errors => On => On
swoole.enable_coroutine => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608
swoole.use_shortname => On => On
`图片描述

图片描述

撰写答案

推广链接