Try setting signal handler before passing control to loop
This commit is contained in:
parent
a81cd4c221
commit
c4cf967198
@ -71,8 +71,7 @@ class Postgres
|
||||
|
||||
while (yield $result->advance()) {
|
||||
$row = $result->getCurrent();
|
||||
if ($row===false)
|
||||
{
|
||||
if ($row===false) {
|
||||
yield $connection->query("
|
||||
CREATE DATABASE {$db}
|
||||
OWNER {$user}
|
||||
@ -92,7 +91,7 @@ class Postgres
|
||||
END IF;
|
||||
END;
|
||||
$$ language 'plpgsql'
|
||||
");
|
||||
");
|
||||
$connection->close();
|
||||
} catch (\Throwable $e) {
|
||||
Logger::log($e->getMessage(), Logger::ERROR);
|
||||
|
@ -9,7 +9,6 @@ use Amp\Sql\ResultSet;
|
||||
use danog\MadelineProto\Logger;
|
||||
use function Amp\call;
|
||||
|
||||
|
||||
class PostgresArray implements DbArray
|
||||
{
|
||||
use ArrayCacheTrait;
|
||||
@ -39,7 +38,8 @@ class PostgresArray implements DbArray
|
||||
|
||||
$this->setCache($index, $value);
|
||||
|
||||
$request = $this->request("
|
||||
$request = $this->request(
|
||||
"
|
||||
INSERT INTO \"{$this->table}\"
|
||||
(key,value)
|
||||
VALUES (:index, :value)
|
||||
@ -79,7 +79,7 @@ class PostgresArray implements DbArray
|
||||
private function prepareTable()
|
||||
{
|
||||
Logger::log("Creating/checking table {$this->table}", Logger::WARNING);
|
||||
|
||||
|
||||
yield $this->request("
|
||||
CREATE TABLE IF NOT EXISTS \"{$this->table}\"
|
||||
(
|
||||
@ -381,4 +381,4 @@ class PostgresArray implements DbArray
|
||||
return $result;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +23,6 @@ use danog\Loop\ResumableSignalLoop;
|
||||
use danog\MadelineProto\Loop\InternalLoop;
|
||||
use danog\MadelineProto\MTProto;
|
||||
|
||||
use function Amp\delay;
|
||||
|
||||
/**
|
||||
* Update feed loop.
|
||||
*
|
||||
|
@ -28,7 +28,6 @@ use danog\MadelineProto\Db\DbArray;
|
||||
use danog\MadelineProto\Db\DbPropertiesFabric;
|
||||
use danog\MadelineProto\Db\DbPropertiesTrait;
|
||||
use danog\MadelineProto\Db\Mysql;
|
||||
use danog\MadelineProto\Db\Pgsql;
|
||||
use danog\MadelineProto\Ipc\Server;
|
||||
use danog\MadelineProto\Loop\Generic\PeriodicLoopInternal;
|
||||
use danog\MadelineProto\Loop\Update\FeedLoop;
|
||||
|
@ -262,6 +262,8 @@ class Magic
|
||||
if (\defined(\SIGINT::class)) {
|
||||
//if (function_exists('pcntl_async_signals')) pcntl_async_signals(true);
|
||||
try {
|
||||
\pcntl_signal(SIGINT, fn () => null);
|
||||
\pcntl_signal(SIGINT, SIG_DFL);
|
||||
Loop::unreference(Loop::onSignal(SIGINT, static function () {
|
||||
Logger::log('Got sigint', Logger::FATAL_ERROR);
|
||||
Magic::shutdown(1);
|
||||
|
Loading…
Reference in New Issue
Block a user