reconstruire UC inceput

This commit is contained in:
andrei-mihnea-cerbu
2024-04-03 04:07:20 +03:00
parent af8c295d75
commit 5e4a488bfd
36 changed files with 264 additions and 943 deletions
+23 -1
View File
@@ -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}`);
});