phpdic/swoole-auto-restart

swwole开发,修改代码后自动重启服务。

0.0.1 2018-12-14 07:05 UTC

This package is auto-updated.

Last update: 2024-09-08 14:04:27 UTC


README

.

说明

此扩展包用于swwole开发,修改代码后自动重启服务。

依赖PHP扩展

  • swoole
    pecl install swoole
  • inotify,此扩展为php文件监听扩展,安装命令如下
    pecl install inotify

安装

$ composer require phpdic/swoole-auto-restart -vvv

用法

1. 在你的项目根目录建立一个php脚本,例如:swoole-auto-start.php,内容如下

require './vendor/autoload.php';

//启动服务的脚本,修改成你自己的
$startServiceCommand='/usr/bin/php easyswoole start';

$a = new \Phpdic\SwooleAutoRestart\swooleAutoRestart(__DIR__, $startServiceCommand);
$a->listen();

2. 执行你刚刚创建的这个脚本

/usr/bin/php swoole-auto-start.php

说明

swooleAutoRestart构造函数注解

 /**
     * swooleAutoRestart constructor.
     * @param string $rootDir 需要监听的项目根目录
     * @param string $startServerCommand 启动swoole服务器的命令
     * @param array $notCheckDir 配置不需要监听的目录
     * @param int $restartInterval 重启间隔
     * @param bool $showDetail 是否展示详细信息
     */
    public function __construct(string $rootDir,string $startServerCommand,array $notCheckDir=[],$restartInterval=1000,$showDetail=false)
    {

notCheckDir参数可以配置不需要监听的目录,例如,我的项目是laravel框架,设置如下

$notCheckDir=['/bootstrap','/storage','/tests']

贡献

你可以通过以下三种方式之一进行贡献

  1. 使用 问题跟踪器 提交错误报告。
  2. 问题跟踪器 上回答问题或修复错误。
  3. 贡献新功能或更新wiki。

代码贡献过程并不非常正式。你只需确保遵循PSR-0、PSR-1和PSR-2编码规范。任何新的代码贡献都必须附有相应的单元测试(如果适用)。

许可协议

MIT