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();
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"
script="$MYTRUEDIR${WRAPPEDPATH:+/$WRAPPEDPATH}/${MYNAME%.php}.php"
[ -f /g/init.env ] && source /g/init.env
www_data="${DEVUSER_USERENT%%:*}"
[ -n "$www_data" ] || www_data=www-data

View File

@ -30,6 +30,13 @@ class SqliteStorage extends CapacitorStorage {
protected function _afterCreate(CapacitorChannel $channel): void {
$db = $this->db;
$name = $this->db->get([
"select name from sqlite_schema",
"where" => ["name" => "_channels"],
]);
if ($name === null) {
# ne pas créer si la table existe déjà, pour éviter d'avoir besoin d'un
# verrou en écriture
$db->exec([
"create table if not exists",
"table" => "_channels",
@ -39,6 +46,14 @@ class SqliteStorage extends CapacitorStorage {
"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",
@ -50,6 +65,7 @@ class SqliteStorage extends CapacitorStorage {
"suffix" => "on conflict do nothing",
]);
}
}
protected function _beforeReset(CapacitorChannel $channel): void {
$this->db->exec([

View File

@ -61,7 +61,8 @@ class BgLauncherApp extends Application {
$runfile = app::with($appClass)->getRunfile();
switch ($this->action) {
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);
array_splice($args, 0, 0, [
PHP_BINARY,

View File

@ -23,6 +23,9 @@ EOT,
["-c", "--count", "args" => 1,
"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,
"help" => "ne pas installer le gestionnaire de signaux",
],
@ -30,9 +33,12 @@ EOT,
protected $count = 100;
protected bool $forceEnabled = false;
protected bool $installSignalHandler = true;
function main() {
app::check_bgapplication_enabled($this->forceEnabled);
if ($this->installSignalHandler) app::install_signal_handler();
$count = intval($this->count);
msg::info("Starting train for ".words::q($count, "step#s"));

View File

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