add support of process signals

This commit is contained in:
Beu 2023-12-01 19:05:24 +01:00
parent 251988b19b
commit 93423e36af
2 changed files with 8 additions and 0 deletions

View File

@ -28,6 +28,9 @@ if (!ini_get('date.timezone') && function_exists('date_default_timezone_set')) {
// Make sure garbage collection is enabled // Make sure garbage collection is enabled
gc_enable(); gc_enable();
// Listen process signals
pcntl_async_signals(true);
// Register AutoLoader // Register AutoLoader
require_once MANIACONTROL_PATH . 'core' . DIRECTORY_SEPARATOR . 'AutoLoader.php'; require_once MANIACONTROL_PATH . 'core' . DIRECTORY_SEPARATOR . 'AutoLoader.php';
\ManiaControl\AutoLoader::register(); \ManiaControl\AutoLoader::register();

View File

@ -652,6 +652,11 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
Logger::log('Starting ManiaControl v' . self::VERSION . '!'); Logger::log('Starting ManiaControl v' . self::VERSION . '!');
try { try {
// Manage SIGTERM signal
pcntl_signal(SIGTERM, function() {
$this->quit("Stop signal received from the OS.", false);
});
// Connect to server // Connect to server
$this->connect(); $this->connect();