Commit d744eb4d authored by NGPixel's avatar NGPixel

feat: Graceful shutdown with git sync

parent f5cce0e1
FROM node:latest
FROM node:6-alpine
ENV WIKI_JS_DOCKER 1
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
RUN yarn add wiki.js@latest
RUN npm install wiki.js@latest
EXPOSE 3000
CMD [ "node", "server" ]
......@@ -92,6 +92,7 @@
"mongodb": "^2.2.26",
"mongoose": "^4.9.9",
"multer": "^1.3.0",
"node-graceful": "^0.2.3",
"ora": "^1.2.0",
"passport": "^0.3.2",
"passport-azure-ad-oauth2": "0.0.4",
......
......@@ -16,9 +16,9 @@ const IS_DEBUG = process.env.NODE_ENV === 'development'
process.env.VIPS_WARNING = false
if (IS_DEBUG) {
require('@glimpse/glimpse').init()
}
// if (IS_DEBUG) {
// require('@glimpse/glimpse').init()
// }
let appconf = require('./libs/config')()
global.appconfig = appconf.config
......@@ -62,6 +62,7 @@ const passport = require('passport')
const passportSocketIo = require('passport.socketio')
const session = require('express-session')
const SessionMongoStore = require('connect-mongo')(session)
const graceful = require('node-graceful')
const socketio = require('socket.io')
var mw = autoload(path.join(SERVERPATH, '/middlewares'))
......@@ -257,6 +258,14 @@ bgAgent.on('message', m => {
}
})
process.on('exit', (code) => {
bgAgent.disconnect()
// ----------------------------------------
// Graceful shutdown
// ----------------------------------------
graceful.on('exit', () => {
global.winston.info('- SHUTTING DOWN - Performing git sync...')
return global.git.resync().then(() => {
global.winston.info('- SHUTTING DOWN - Git sync successful. Now safe to exit.')
process.kill(process.pid, 'SIGINT')
})
})
This diff was suppressed by a .gitattributes entry.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment