Skip to content

Commit

Permalink
example: update exitHook
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaojue committed Feb 29, 2024
1 parent 9c71854 commit 1067ba3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion example/05-lifecycle/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Daruk, DarukContext, DarukServer } from '../../src';
import { Daruk, DarukContext, DarukServer, darukContainer, TYPES } from '../../src';

(async () => {
let app = DarukServer({
Expand All @@ -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);
})();

0 comments on commit 1067ba3

Please sign in to comment.