swoole-framwork/boot.php
2024-05-21 14:33:56 +08:00

33 lines
1.0 KiB
PHP

<?php
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . "/app/config/define.php";
\Swoole\Runtime::enableCoroutine(true);
use Swoole\Process;
if ($argc == 2) {
$cmd = $argv[1];
if ($cmd == 'start') {
$http = new Core\server\HttpServer('first');
$http->run();
} 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);
$http = new Core\server\HttpServer('first');
echo "restart done" . PHP_EOL;
$http->run();
} else {
echo "restart the failure" . PHP_EOL;
}
} else {
echo '无效命令';
}
}