用AI赚第一桶💰低成本搭建一套AI赚钱工具,源码可二开。 广告
## 服务器 官方开发的同步服务器,用于执行 "同步阻塞代码",基于 [mix/sync-invoke](https://github.com/mix-php/sync-invoke) 封装。 ## 启动 启动服务器: ~~~ php bin/mix.php invoker ~~~ 以上命令的各部分拆解如下: - `bin/mix.php` 为入口文件 - `invoker` 为命令 查看帮助: ~~~ php bin/mix.php invoker --help ~~~ `invoker` 包含以下可选参数: - `-d, --daemon` 程序在后台执行 - `-p, --port` 指定服务器端口 - `-r, --reuse-port ` 端口复用,用于多开利用多核 ## 入口代码 从 `manifest.php` 的 `commands` 或者 `commandPath` 配置我们能看到 `si:start` 命令启动的是: [>> \App\SyncInvoke\Commands\StartCommand::class <<](https://github.com/mix-php/mix-skeleton/blob/master/app/SyncInvoke/Commands/StartCommand.php) - 代码非常简单,就是启动官方提供的 Mix\Sync\Invoke\Server,使用同步调用并不需要修改 app/src/Sync 模块中的代码,只需启动与重启该服务。 ## 命令管理 与 mix 之前版本不同的是,新版只提供了 start 命令,这是因为新版 mix 是单进程协程框架,因为是单进程所以可以直接通过 kill 停止执行,停止是平滑安全的这一点能在 StartCommand::class 的源码中看到实现逻辑: ``` // 查找名为 mix 的进程 $> ps -ef | grep mix // kill指定pid $> kill [PID] ``` ## 热更新 (仅限开发阶段使用) 为了提升开发效率,我们提供了 [https://github.com/mix-php/swoolefor](https://github.com/mix-php/swoolefor) 工具,能监控文件系统变化,通过设置的命令自动重启服务器,可用于修改代码后自动重启各种 Swoole 常驻服务器 (仅限开发阶段使用)