Closed cesurapp closed 2 years ago
You can use either co\run to create context or use server callback to create. Remove co\run it should work.
I tried and the result is the same.
echo 'Starting server ...'.PHP_EOL;
$server = new \Swoole\Http\Server('127.0.0.1', 9502);
$server->set([
\Swoole\Constant::OPTION_ENABLE_COROUTINE => false,
]);
\Swoole\Process::signal(SIGTERM, function (int $signal) {
// Disable SIGTERM - SIGINT vs.
});
$server->start();
Starting server ...
PHP Warning: Swoole\Server::start(): eventLoop has already been created, unable to start Swoole\Http\Server in /Users/ramazanapaydin/www/ec/test/api/bin/index.php on line 13
Try it yourself. I've been dealing with this for 2 days.
I don’t know what you like to archive. Please check server docs at https://openswoole.com/docs/modules/swoole-server-doc Normally, you should not mix server with process.
I think he wanted to react to SIGTERM while running the server. Is there any other way to achieve this?
I think he wanted to react to SIGTERM while running the server. Is there any other way to achieve this?
Like this:
function signal_handler($signal){
$GLOBALS['server']->shutdown();
}
pcntl_signal(SIGINT, "signal_handler");
pcntl_signal(SIGTERM, "signal_handler");
Swoole\Timer::tick(200, function(){
pcntl_signal_dispatch();
});
Please answer these questions before submitting your issue.
What did you do? If possible, provide a simple script for reproducing the error.
What did you expect to see?
What did you see instead?
Warning: Swoole\Server::start(): eventLoop has already been created, unable to start Swoole\Http\Server in /Users/ramazanapaydin/www/ec/test/api/bin/index.php on line 14
What version of OpenSwoole are you using (show your
php --ri openswoole
)? 4.10.0What is your machine environment used (show your
uname -a
&php -v
&gcc -v
) ? PHP 8.1.3 Macos 11.6.4