Add systemd-compatible service manager notification after bewCloud has successfully started (#137)

* Add systemd-compatible service manager notification after bewCloud has successfully started

* Use `systemd-notify` util instead of native integration while Deno APIs aren’t there yet

* Implement different approach for systemd-notification reporting

I went with a slightly different option, given I was struggling to lose a lot of flexibility in the original listening log (because it's started with some server state parameters) or allow so much unnecessary/duplicate complexity from Fresh in `fresh.config.ts` because I'll probably eventually ditch it (given #99).

Some relevant references in the original `fresh` code:

- ab14d1044c/docs/1.x/concepts/server-configuration.md (L207-L208)
- d9764e2005/src/server/config.ts (L95)
- d9764e2005/src/server/mod.ts (L115-L118)
- d9764e2005/src/server/boot.ts (L52-L57)

* Remove unnecessary comments

---------

Co-authored-by: Bruno Bernardino <me@brunobernardino.com>
This commit is contained in:
Erin of Yukis 2026-01-02 10:15:25 +00:00 committed by GitHub
parent 69995c422e
commit 777a26f492
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,8 +5,24 @@ import { startCrons } from '/crons/index.ts';
const isBuildMode = Deno.args.includes('build');
async function notifyServiceManagerReady() {
const socketAddress = Deno.env.get('NOTIFY_SOCKET');
if (typeof socketAddress !== 'string') {
return;
}
const result = await (new Deno.Command('systemd-notify', {
args: ['--ready', `MESSAGE=bewCloud is ready`],
})).output();
if (!result.success) {
const output = new TextDecoder().decode(result.stderr);
throw new Deno.errors.NotCapable(`Failed to execute “systemd-notify”: ${output} (code ${result.code})`);
}
}
if (!isBuildMode) {
await startCrons();
await notifyServiceManagerReady();
}
export default defineConfig({