feat: 初始化雄戈商城服务端代码与Webhook自动部署配置
这个提交包含在:
79
addons/shopro/command/Chat.php
普通文件
79
addons/shopro/command/Chat.php
普通文件
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* run with command
|
||||
* php start.php start
|
||||
*/
|
||||
|
||||
namespace addons\shopro\command;
|
||||
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Argument;
|
||||
use think\console\Output;
|
||||
use Workerman\Worker;
|
||||
use addons\shopro\library\chat\Start;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Chat extends Command
|
||||
{
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('shopro:chat')
|
||||
->addArgument('action', Argument::OPTIONAL, "action start [d]|stop|restart|status")
|
||||
->addArgument('type', Argument::OPTIONAL, "d -d")
|
||||
->setHelp('此命令是用来启动 shopro 商城的客服服务端进程')
|
||||
->setDescription('shopro 客服');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
global $argv;
|
||||
$action = trim($input->getArgument('action'));
|
||||
$type = trim($input->getArgument('type')) ? '-d' : '';
|
||||
|
||||
$argv[0] = 'shopro:chat';
|
||||
$argv[1] = $action;
|
||||
$argv[2] = $type ? '-d' : '';
|
||||
$this->start($input, $output);
|
||||
}
|
||||
|
||||
private function start($input, $output)
|
||||
{
|
||||
if (strpos(strtolower(PHP_OS), 'win') === 0) {
|
||||
$output->writeln("<error>GatewayWorker Not Support On Windows.</error>");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// 检查扩展
|
||||
if (!extension_loaded('pcntl')) {
|
||||
$output->writeln("<error>Please install pcntl extension.</error>");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!extension_loaded('posix')) {
|
||||
$output->writeln("<error>Please install posix extension.</error>");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// 实例化启动类
|
||||
$startServer = new Start();
|
||||
|
||||
// 启动 register
|
||||
$startServer->register();
|
||||
|
||||
// 启动 businessWorker
|
||||
$startServer->businessWorker();
|
||||
|
||||
// 启动 gateway
|
||||
$startServer->gateway();
|
||||
|
||||
// 设置日志
|
||||
$startServer->setLog(__DIR__ . '/../');
|
||||
|
||||
// 运行所有服务
|
||||
Worker::runAll();
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户