Skip to content

Commit

Permalink
graceful exit
Browse files Browse the repository at this point in the history
  • Loading branch information
kukhariev committed Feb 9, 2018
1 parent bc1a9dc commit 2cdd220
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions server/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
/*--------------------------------------------------------------
* Copyright (c) 2018, Oleg Kukhariev. All rights reserved.
* Licensed under the MIT License.
*-------------------------------------------------------------*/

'use strict';

/*
*
* ngx-uploadx server example
*
* Server API eximple
*/

const bytes = require('bytes');
const crypto = require('crypto');
const express = require('express');
Expand Down Expand Up @@ -181,3 +187,10 @@ app.use((err, req, res, next) => { // eslint-disable-line
const server = app.listen(PORT, 'localhost', () => {
console.log(`Server listening on port: ${server.address().port}`);
});

process.on('SIGTERM', () => {
server.close(() => {
process.exit(0);
});

});

0 comments on commit 2cdd220

Please sign in to comment.