-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Octane doesn't drop connections after docker container stopped #851
Comments
Another way to check the bug:
In case of docker, we are stopping whole system that run octane. docker-entrypoint.sh #!/bin/bash
# Function to handle the SIGTERM signal
_term() {
echo "Caught SIGTERM signal!"
# Execute any command before shutdown
echo "Stopping Laravel Octane gracefully..."
php artisan octane:stop
exit 0
}
# Trap the SIGTERM signal and link it to the _term function
trap _term SIGTERM
# Your original CMD commands, moved to the background
php artisan octane:start --workers=2 --task-workers=2 --host=0.0.0.0 &
# Grab the last background process's PID
pid=$!
# Wait for this process to end
wait $pid But docker sigterm is unstable, and we afraid that we will have problems in AWS ECR or Kubernetes (but kub, also has ability to run scripts before termination)... We need ability to close octane with parent process, if that can be done. Or maybe you have other solutions <3 |
i've already tried this config, but it won't close the process, when parent process closed.... [
'swoole' => [
'mode' => SWOOLE_BASE,
'options' => [
'daemonize' => 0
]
],
] |
I figure out, that all commands should be extended with /**
* Returns the list of signals to subscribe.
*/
public function getSubscribedSignals() : array
{
return [ SIGINT, SIGTERM, SIGHUP ];
} In that case, server will be stopped, while docker rip bash/sh terminal with sigterm |
Nice that you found a solution. Could you try and PR That? Thanks! |
Octane Version
latest
Laravel Version
11.0.5
PHP Version
8.3
What server type are you using?
Open Swoole
Server Version
docker latest
Database Driver & Version
Mysql 8.3.0
Description
We have a setup with docker + jenkins. When docker stops and starts a new container, the MySQL connection from the old container is still working.
After some time and several reboots, we use up all max_connections in the mysql container.
How i can handle this out?
By the way,
php artisan octane:start --workers=2 --task-workers=2 --host=0.0.0.0
should spawn 4 connections, i believe, but in my test, it spawn ~10We can play with global variable in MySql, such as wait_timeout to force it close connection, but i want to discuss some other solutions, if such exist
Steps To Reproduce
openswoole
and run it throughphp artisan octane:start --workers=2 --task-workers=2 --host=0.0.0.0
The text was updated successfully, but these errors were encountered: