xiaodi/xiaodi-worker

v0.3.3 2019-05-27 05:05 UTC

This package is auto-updated.

Last update: 2024-10-28 00:49:40 UTC


README

ThinkPHP5.1 命令行启动多个Workerman 服务

Latest Stable Version Total Downloads Latest Unstable Version LICENSE Monthly Downloads Daily Downloads

安装

composer require xiaodi/xiaodi-worker

配置

以下使用了think-worker包
application/Worker/Http.php

<?php
namespace app\Worker;

use think\worker\Server;

class Http extends Server
{
    protected $socket = 'http://0.0.0.0:55555';

    public function onMessage($connection,$data)
    {
      $connection->send(json_encode($data));
    }
}

config/service.php

Http: 服务名称 \app\Worker\Http: 服务的具体命名空间

<?php

return [
  'Http' => '\app\Worker\Http'
];

命令

参数一 服务名称
参数二 命令 如 [start|stop|reload|restart|status]
参数三 是否守护进程模式

php think service:run 参数一 参数二 参数三

启动

原生支持的命令 [start|stop|reload|restart|status]

php think service:run Http start

守护进程

php think service:run Http start -d