nginx #2

Merged
mb merged 10 commits from nginx into master 2024-02-04 00:37:33 +01:00
Showing only changes of commit 8aac0b8bde - Show all commits

View file

@ -53,17 +53,20 @@ export function loop_process(
on_start: opts?.on_start ?? async_noop,
on_stop: opts?.on_stop ?? async_noop,
};
const control = {
do_continue: true,
child_process: null as null | Deno.ChildProcess,
};
const kill_sig = channel<"kill">();
kill_sig.receive().then(() => {
control.do_continue = false;
control.child_process?.kill();
});
async function launch() {
while (true) {
while (control.do_continue) {
await events.on_start();
const child_process = command.spawn();
const result = await Promise.any([kill_sig.receive(), child_process.output()]);
if (result === "kill") {
await events.on_stop();
child_process.kill();
break;
}
control.child_process = command.spawn();
await control.child_process.output();
await events.on_stop();
await sleep(opts?.delay ?? 500);
}