2024-05-20 11:51:07 +08:00
|
|
|
<?php
|
2024-05-21 14:33:56 +08:00
|
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
|
|
require_once __DIR__ . "/app/config/define.php";
|
|
|
|
\Swoole\Runtime::enableCoroutine(true);
|
2024-05-31 14:57:01 +08:00
|
|
|
// command swoole-cli boot.php start
|
2024-05-20 11:51:07 +08:00
|
|
|
use Swoole\Process;
|
2024-05-31 14:57:01 +08:00
|
|
|
use Core\server\HttpServer;
|
2024-05-21 14:33:56 +08:00
|
|
|
if ($argc == 2) {
|
2024-05-20 11:51:07 +08:00
|
|
|
$cmd = $argv[1];
|
2024-05-21 14:33:56 +08:00
|
|
|
if ($cmd == 'start') {
|
2024-05-31 14:57:01 +08:00
|
|
|
$http = new HttpServer();
|
2024-05-20 11:51:07 +08:00
|
|
|
$http->run();
|
2024-05-21 14:33:56 +08:00
|
|
|
} else if ($cmd == 'stop') {
|
|
|
|
$getpid = intval(file_get_contents("./Buddha.pid")); //获取上一次程序运行的 master_id
|
|
|
|
if ($getpid && trim($getpid) != 0) {
|
|
|
|
Process::kill($getpid);
|
|
|
|
echo "stop success" . PHP_EOL;
|
|
|
|
}
|
|
|
|
} else if ($cmd == 'restart') {
|
|
|
|
$getpid = intval(file_get_contents("./Buddha.pid")); //获取上一次程序运行的 master_id
|
|
|
|
if ($getpid && trim($getpid) != 0) {
|
|
|
|
Process::kill($getpid);
|
|
|
|
sleep(1);
|
2024-05-31 14:57:01 +08:00
|
|
|
$http = new Core\server\HttpServer();
|
2024-05-21 14:33:56 +08:00
|
|
|
echo "restart done" . PHP_EOL;
|
|
|
|
$http->run();
|
|
|
|
} else {
|
|
|
|
echo "restart the failure" . PHP_EOL;
|
2024-05-20 11:51:07 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
echo '无效命令';
|
|
|
|
}
|
2024-05-21 14:33:56 +08:00
|
|
|
}
|