1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-27 11:34:41 +01:00

Final fix

This commit is contained in:
Daniil Gentili 2021-04-07 21:58:48 +02:00
parent f9e5d7be36
commit 3b8301217f
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 3 additions and 2 deletions

View File

@ -23,6 +23,7 @@ use danog\MadelineProto\Logger;
use danog\MadelineProto\Magic;
use danog\MadelineProto\SessionPaths;
use danog\MadelineProto\Settings\Ipc;
use danog\MadelineProto\Shutdown;
use danog\MadelineProto\Tools;
(static function (): void {
@ -108,6 +109,7 @@ use danog\MadelineProto\Tools;
try {
Tools::wait($session->storeIpcState(new IpcState($runnerId)));
Tools::wait(Server::waitShutdown());
Shutdown::removeCallback('restarter');
return;
} catch (\Throwable $e) {
Logger::log((string) $e, Logger::FATAL_ERROR);

View File

@ -72,14 +72,13 @@ trait Loop
$url = \explode('?', $uri, 2)[0] ?? '';
$query = \http_build_query($params);
$uri = \implode('?', [$url, $query]);
$payload = $_SERVER['REQUEST_METHOD'].' '.$uri.' '.$_SERVER['SERVER_PROTOCOL']."\r\n".'Host: '.$_SERVER['SERVER_NAME']."\r\n\r\n";
$payload = $_SERVER['REQUEST_METHOD'].' '.$uri." HTTP/1.1\r\n".'Host: '.$_SERVER['SERVER_NAME']."\r\n\r\n";
$logger->logger("Connecting to {$address}:{$port}");
$a = \fsockopen($address, $port);
$logger->logger("Sending self-restart payload");
$logger->logger($payload);
\fwrite($a, $payload);
$logger->logger("Payload sent with token {$params['MadelineSelfRestart']}, waiting for self-restart");
\sleep(10);
\fclose($a);
$logger->logger("Shutdown of self-restart callback");
}, 'restarter');