diff --git a/example/05-lifecycle/index.ts b/example/05-lifecycle/index.ts index 9dbfd54..90c0a43 100644 --- a/example/05-lifecycle/index.ts +++ b/example/05-lifecycle/index.ts @@ -1,4 +1,4 @@ -import { Daruk, DarukContext, DarukServer } from '../../src'; +import { Daruk, DarukContext, DarukServer, darukContainer, TYPES } from '../../src'; (async () => { let app = DarukServer({ @@ -18,5 +18,14 @@ import { Daruk, DarukContext, DarukServer } from '../../src'; await app.loadFile('./controllers'); await app.binding(); + const DarukExitHook = darukContainer.getNamed(TYPES.PluginInstance, 'DarukExitHook'); + //@ts-ignore + DarukExitHook.addHook(async (err, cb) => { + setTimeout(() => { + console.log(err, 'exit hook !!!'); + cb(); + }, 1000); + }); + app.listen(port); })();