reconstruire UC inceput
This commit is contained in:
+23
-1
@@ -7,6 +7,26 @@ const cookieParser = require('cookie-parser');
|
||||
|
||||
const checkSession = require('./middlewares/checkSession');
|
||||
|
||||
process.on('SIGINT', shutdown);
|
||||
process.on('SIGTERM', shutdown);
|
||||
|
||||
function shutdown() {
|
||||
console.log('Received kill signal, shutting down gracefully.');
|
||||
const serverProcess = app.get('serverProcess');
|
||||
if (serverProcess && typeof serverProcess.kill === 'function') {
|
||||
console.log('Shutting down server process...');
|
||||
serverProcess.kill(); // Send SIGTERM to server process
|
||||
|
||||
serverProcess.on('exit', () => {
|
||||
console.log('Server process terminated.');
|
||||
process.exit(0); // Exit main process cleanly
|
||||
});
|
||||
} else {
|
||||
console.log('No server process or cannot be killed, exiting.');
|
||||
process.exit(0); // Exit main process cleanly
|
||||
}
|
||||
}
|
||||
|
||||
const app = express()
|
||||
|
||||
app.set('serverProcess', null);
|
||||
@@ -18,7 +38,7 @@ app.use(bodyParser.json());
|
||||
app.use(express.static(path.join(__dirname, 'public', 'html')));
|
||||
app.use('/css', express.static(path.join(__dirname, 'public', 'css')));
|
||||
app.use('/js', express.static(path.join(__dirname, 'public', 'js')));
|
||||
app.use('/images', express.static(path.join(__dirname, 'public', 'assets')));
|
||||
app.use('/images', express.static(path.join(__dirname, 'public', 'images')));
|
||||
|
||||
app.use(checkSession);
|
||||
|
||||
@@ -31,3 +51,5 @@ const PORT = process.env.PORT || 80;
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server is running on port ${PORT}`);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user