feat: Graceful shutdown with git sync
This commit is contained in:
parent
f5cce0e1f4
commit
d744eb4d4c
@ -1,10 +1,10 @@
|
||||
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')
|
||||
})
|
||||
})
|
||||
|
@ -4569,6 +4569,10 @@ node-abi@^2.0.0:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-2.0.2.tgz#00f3e0a58100eb480133b48c99a32cc1f9e6c93e"
|
||||
|
||||
node-graceful@^0.2.3:
|
||||
version "0.2.3"
|
||||
resolved "https://registry.yarnpkg.com/node-graceful/-/node-graceful-0.2.3.tgz#ab120e1eed8c0c2b5e2ac874bf2754519c3fa942"
|
||||
|
||||
node-gyp@^3.3.1:
|
||||
version "3.6.1"
|
||||
resolved "https://registry.yarnpkg.com/node-gyp/-/node-gyp-3.6.1.tgz#19561067ff185464aded478212681f47fd578cbc"
|
||||
|
Loading…
Reference in New Issue
Block a user