bewcloud/fresh.config.ts
Erin of Yukis 777a26f492
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>
2026-01-02 10:15:25 +00:00

30 lines
831 B
TypeScript

import { defineConfig } from 'fresh/server.ts';
import tailwind from 'fresh/plugins/tailwind.ts';
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({
plugins: [tailwind()],
});