lease-script: do not run too many instances of scripts

Every instance of the scripts does all the work. If one script is running
and a second script is waiting we do not have to start a third one.
This commit is contained in:
Christian Hesse 2021-07-01 18:07:23 +02:00
parent 5f2bc87b22
commit 9c9fb46e4a
1 changed files with 7 additions and 5 deletions

View File

@ -27,10 +27,12 @@ $LogPrintExit2 debug $0 ("DHCP Server " . $leaseServerName . " " . \
:foreach Script in=[ / system script find where source~("\n# provides: lease-script " . $State . "\n") ] do={
:local ScriptName [ / system script get $Script name ];
:do {
$LogPrintExit2 debug $0 ("Running script: " . $ScriptName) false;
/ system script run $Script;
} on-error={
$LogPrintExit2 warning $0 ("Running script '" . $ScriptName . "' failed!") false;
:if ([ :len [ / system script job find where script=$ScriptName ] ] < 2) do={
:do {
$LogPrintExit2 debug $0 ("Running script: " . $ScriptName) false;
/ system script run $Script;
} on-error={
$LogPrintExit2 warning $0 ("Running script '" . $ScriptName . "' failed!") false;
}
}
}