Recipes
Restart or shut down the runtime
import { restart, shutdown } from '@quik/bootstrap';
await shutdown(); // runs teardown (AFTER_BOOT) hooks once
await restart(); // teardown, RESET hooks, reload bootstrap setup, then boot again
restart() reloads the runtime from the IQBootstrapSetup options passed to the last Module.setup(...) call.
Trigger a restart via an event
import { BootstrapEvent, BootstrapEvents } from '@quik/bootstrap';
BootstrapEvents.emit(BootstrapEvent.RESTART);
Useful for fire-and-forget restarts triggered from outside the normal lifecycle (e.g. a signal handler).
Register hooks by explicit lifecycle action
import { onAction } from '@quik/bootstrap';
import { BootstrapHook } from '@quik/bootstrap';
onAction(BootstrapHook.AFTER_INIT, async () => {
// runs once, after every module's onAfterInit hook
});
Declare module dependencies
A module loaded through Module.setup can require other modules to load first:
export const ModuleName = '@app/billing';
export const Dependencies = ['@quik/database'];
export async function setup(options) {
// options is IQModuleSetup: isCli, startHttpServer, startWebSocketServer, startScheduler, isTest
}
Bootstrap resolves Dependencies before loading the module; a missing dependency throws ModuleNotLoadedError.