modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2024-09-30 16:22:33 +04:00
parent 57759c2d51
commit a257eeb478
6 changed files with 51 additions and 18 deletions

View File

@ -454,4 +454,8 @@ EOT);
} }
abstract function main(); abstract function main();
static function runfile(): RunFile {
return app::with(static::class)->getRunfile();
}
} }

View File

@ -32,6 +32,8 @@ launcher="$MYTRUEDIR/$LAUNCHERPATH"
class="$MYTRUEDIR${WRAPPEDPATH:+/$WRAPPEDPATH}/${MYNAME%.php}.phpc" class="$MYTRUEDIR${WRAPPEDPATH:+/$WRAPPEDPATH}/${MYNAME%.php}.phpc"
script="$MYTRUEDIR${WRAPPEDPATH:+/$WRAPPEDPATH}/${MYNAME%.php}.php" script="$MYTRUEDIR${WRAPPEDPATH:+/$WRAPPEDPATH}/${MYNAME%.php}.php"
[ -f /g/init.env ] && source /g/init.env
www_data="${DEVUSER_USERENT%%:*}" www_data="${DEVUSER_USERENT%%:*}"
[ -n "$www_data" ] || www_data=www-data [ -n "$www_data" ] || www_data=www-data

View File

@ -30,25 +30,41 @@ class SqliteStorage extends CapacitorStorage {
protected function _afterCreate(CapacitorChannel $channel): void { protected function _afterCreate(CapacitorChannel $channel): void {
$db = $this->db; $db = $this->db;
$db->exec([ $name = $this->db->get([
"create table if not exists", "select name from sqlite_schema",
"table" => "_channels", "where" => ["name" => "_channels"],
"cols" => [
"name" => "varchar primary key",
"table_name" => "varchar",
"class" => "varchar",
],
]); ]);
$db->exec([ if ($name === null) {
"insert", # ne pas créer si la table existe déjà, pour éviter d'avoir besoin d'un
"into" => "_channels", # verrou en écriture
"values" => [ $db->exec([
"name" => $channel->getName(), "create table if not exists",
"table_name" => $channel->getTableName(), "table" => "_channels",
"class" => get_class($channel), "cols" => [
], "name" => "varchar primary key",
"suffix" => "on conflict do nothing", "table_name" => "varchar",
"class" => "varchar",
],
]);
}
$name = $this->db->get([
"select name from _channels",
"where" => ["name" => $channel->getName()],
]); ]);
if ($name === null) {
# ne pas insérer si la ligne existe déjà, pour éviter d'avoir besoin d'un
# verrou en écriture
$db->exec([
"insert",
"into" => "_channels",
"values" => [
"name" => $channel->getName(),
"table_name" => $channel->getTableName(),
"class" => get_class($channel),
],
"suffix" => "on conflict do nothing",
]);
}
} }
protected function _beforeReset(CapacitorChannel $channel): void { protected function _beforeReset(CapacitorChannel $channel): void {

View File

@ -61,7 +61,8 @@ class BgLauncherApp extends Application {
$runfile = app::with($appClass)->getRunfile(); $runfile = app::with($appClass)->getRunfile();
switch ($this->action) { switch ($this->action) {
case self::ACTION_START: case self::ACTION_START:
$appClass::_manage_runfile(count($args), $args, $runfile); $argc = count($args);
$appClass::_manage_runfile($argc, $args, $runfile);
if ($runfile->warnIfLocked()) self::exit(app::EC_LOCKED); if ($runfile->warnIfLocked()) self::exit(app::EC_LOCKED);
array_splice($args, 0, 0, [ array_splice($args, 0, 0, [
PHP_BINARY, PHP_BINARY,

View File

@ -23,6 +23,9 @@ EOT,
["-c", "--count", "args" => 1, ["-c", "--count", "args" => 1,
"help" => "spécifier le nombre d'étapes", "help" => "spécifier le nombre d'étapes",
], ],
["-f", "--force-enabled", "value" => true,
"help" => "lancer la commande même si les tâches planifiées sont désactivées",
],
["-n", "--no-install-signal-handler", "value" => false, ["-n", "--no-install-signal-handler", "value" => false,
"help" => "ne pas installer le gestionnaire de signaux", "help" => "ne pas installer le gestionnaire de signaux",
], ],
@ -30,9 +33,12 @@ EOT,
protected $count = 100; protected $count = 100;
protected bool $forceEnabled = false;
protected bool $installSignalHandler = true; protected bool $installSignalHandler = true;
function main() { function main() {
app::check_bgapplication_enabled($this->forceEnabled);
if ($this->installSignalHandler) app::install_signal_handler(); if ($this->installSignalHandler) app::install_signal_handler();
$count = intval($this->count); $count = intval($this->count);
msg::info("Starting train for ".words::q($count, "step#s")); msg::info("Starting train for ".words::q($count, "step#s"));

View File

@ -374,4 +374,8 @@ EOT);
} }
abstract function main(); abstract function main();
static function runfile(): RunFile {
return app::with(static::class)->getRunfile();
}
} }