server graceful reload with PM2 and close on sigints

merge-requests/208/head
fatchan 5 years ago
parent 205b92275a
commit 05977d3cd6
  1. 3
      ecosystem.config.js
  2. 21
      gulp/res/css/style.css
  3. 27
      server.js

@ -8,6 +8,9 @@ module.exports = {
watch: false,
max_memory_restart: '1G',
log_date_format: 'YYYY-MM-DD HH:mm:ss',
wait_ready: true,
listen_timeout: 10000,
kill_timeout: 10000,
env: {
NODE_ENV: 'development'
},

@ -48,9 +48,11 @@ body {
}
.pages {
margin: 10px 0;
box-sizing: border-box;
padding: 10px;
width: max-content;
}
a, a:visited {
text-decoration: underline;
color: #34345C;
@ -207,7 +209,7 @@ td, th {
align-items: center;
}
.post-container, .pages, .toggle-label {
.post-container, .pages, summary {
background: #D6DAF0;
border: 1px solid #B7C5D9;
}
@ -235,8 +237,12 @@ td, th {
box-shadow: inset 0 0 100px 100px rgba(255,255,255,.25);
}
.toggle-label {
summary {
margin-bottom: 1px;
padding: 10px;
}
.toggle-label {
text-align: center;
max-width: 100%;
box-sizing: border-box;
@ -301,9 +307,8 @@ td, th {
text-align: center;
margin: 2px;
margin-top: 0px;
max-width: 160px;
max-width: 128px;
overflow: hidden;
max-width: 160px;
text-overflow: ellipsis;
word-break: keep-all;
}
@ -413,7 +418,7 @@ input textarea {
}
.nav-item {
line-height: 30px;
line-height: 38px;
text-decoration: none;
float: left;
padding-left: 10px;
@ -534,6 +539,10 @@ hr {
height: 8px;
}
.pages {
width:100%;
}
.post-container {
width: 100%;
}

@ -95,8 +95,33 @@ const express = require('express')
})
// listen
app.listen(configs.port, '127.0.0.1', () => {
const server = app.listen(configs.port, '127.0.0.1', () => {
console.log(`Listening on port ${configs.port}`);
});
//let PM@ know that this is ready (forgraceful reloads)
process.send('ready');
process.on('SIGINT', () => {
console.info('SIGINT signal received.')
// Stops the server from accepting new connections and finishes existing connections.
server.close((err) => {
// if error, log and exit with error (1 code)
if (err) {
console.error(err);
process.exit(1);
}
// close database connection
Mongo.client.close();
// now close without error
process.exit(0);
})
})
})();

Loading…
Cancel
Save