Skip to content

Commit

Permalink
Gracefully shutdown: exit after server is closed (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jul 30, 2021
1 parent 9861102 commit 9e0fbda
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/micro/bin/micro.js
Expand Up @@ -204,8 +204,11 @@ function startEndpoint(module, endpoint) {

server.listen(...endpoint, () => {
const details = server.address();

registerShutdown(() => server.close());
registerShutdown(() => {
console.log('micro: Gracefully shutting down. Please wait...');
server.close();
process.exit();
});

// `micro` is designed to run only in production, so
// this message is perfectly for prod
Expand All @@ -225,8 +228,6 @@ async function start() {
for (const endpoint of args['--listen']) {
startEndpoint(loadedModule, endpoint);
}

registerShutdown(() => console.log('micro: Gracefully shutting down. Please wait...'));
}

start();

0 comments on commit 9e0fbda

Please sign in to comment.