Skip to content

Commit

Permalink
feat: Merge pull request #42 from pelias/avoid-process.exit
Browse files Browse the repository at this point in the history
Explicitly close HTTP server to avoid process.exit
  • Loading branch information
orangejulius authored Dec 1, 2017
2 parents 4d77c7d + f1f2cf2 commit 766da53
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const app = require('./app')();

try {
const app = require('./app')();
const port = ( parseInt(process.env.PORT) || 3102 );

app.listen(port, () => {
Expand All @@ -8,6 +9,8 @@ try {

} catch (err) {
console.error(err);
process.exit(1);

// use exitCode to exit safely: https://nodejs.org/api/process.html#process_process_exit_code
process.exitCode = 1;
app.close();
}

0 comments on commit 766da53

Please sign in to comment.