mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #3682 from overleaf/bg-check-maintenance-file
check maintenance file periodically to close site GitOrigin-RevId: 8e29f40a23df96198c6e4603ede2bab852b98740
This commit is contained in:
parent
54212385e6
commit
bc4f5a687a
6 changed files with 35 additions and 19 deletions
|
@ -10,8 +10,14 @@ const {
|
|||
|
||||
module.exports = {
|
||||
check(req, res, next) {
|
||||
if (!settings.siteIsOpen || !settings.editorIsOpen) {
|
||||
// always return successful health checks when site is closed
|
||||
res.contentType('application/json')
|
||||
res.sendStatus(200)
|
||||
} else {
|
||||
// detach from express for cleaner stack traces
|
||||
setTimeout(() => runSmokeTestsDetached(req, res).catch(next))
|
||||
}
|
||||
},
|
||||
|
||||
checkActiveHandles(req, res, next) {
|
||||
|
|
|
@ -98,11 +98,13 @@ const AdminController = {
|
|||
return res.render('admin/register')
|
||||
},
|
||||
|
||||
dissconectAllUsers: (req, res) => {
|
||||
disconnectAllUsers: (req, res) => {
|
||||
logger.warn('disconecting everyone')
|
||||
const delay = (req.query && req.query.delay) > 0 ? req.query.delay : 10
|
||||
EditorRealTimeController.emitToAll(
|
||||
'forceDisconnect',
|
||||
'Sorry, we are performing a quick update to the editor and need to close it down. Please refresh the page to continue.'
|
||||
'Sorry, we are performing a quick update to the editor and need to close it down. Please refresh the page to continue.',
|
||||
delay
|
||||
)
|
||||
return res.sendStatus(200)
|
||||
},
|
||||
|
|
|
@ -954,9 +954,9 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) {
|
|||
AdminController.closeEditor
|
||||
)
|
||||
webRouter.post(
|
||||
'/admin/dissconectAllUsers',
|
||||
'/admin/disconnectAllUsers',
|
||||
AuthorizationMiddleware.ensureUserIsSiteAdmin,
|
||||
AdminController.dissconectAllUsers
|
||||
AdminController.disconnectAllUsers
|
||||
)
|
||||
webRouter.post(
|
||||
'/admin/flushProjectToTpds',
|
||||
|
@ -981,14 +981,20 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) {
|
|||
|
||||
privateApiRouter.post(
|
||||
'/disconnectAllUsers',
|
||||
AdminController.dissconectAllUsers
|
||||
AdminController.disconnectAllUsers
|
||||
)
|
||||
|
||||
privateApiRouter.get('/perfTest', (req, res) => res.send('hello'))
|
||||
|
||||
publicApiRouter.get('/status', (req, res) =>
|
||||
publicApiRouter.get('/status', (req, res) => {
|
||||
if (!Settings.siteIsOpen) {
|
||||
res.send('web site is closed (web)')
|
||||
} else if (!Settings.editorIsOpen) {
|
||||
res.send('web editor is closed (web)')
|
||||
} else {
|
||||
res.send('web sharelatex is alive (web)')
|
||||
)
|
||||
}
|
||||
})
|
||||
privateApiRouter.get('/status', (req, res) =>
|
||||
res.send('web sharelatex is alive (api)')
|
||||
)
|
||||
|
|
|
@ -42,7 +42,7 @@ block content
|
|||
p.small Will stop anyone opening the editor. Will NOT disconnect already connected users.
|
||||
|
||||
.row-spaced
|
||||
form(method='post',action='/admin/dissconectAllUsers')
|
||||
form(method='post',action='/admin/disconnectAllUsers')
|
||||
input(name="_csrf", type="hidden", value=csrfToken)
|
||||
button.btn.btn-danger(type="submit") Disconnect all users
|
||||
p.small Will force disconnect all users with the editor open. Make sure to close the editor first to avoid them reconnecting.
|
||||
|
|
|
@ -25,7 +25,6 @@ block content
|
|||
.global-alerts(ng-cloak ng-hide="editor.error_state")
|
||||
.alert.alert-danger.small(ng-if="connection.forced_disconnect")
|
||||
strong #{translate("disconnected")}
|
||||
| #{translate("please_refresh")}
|
||||
|
||||
.alert.alert-warning.small(ng-if="connection.reconnection_countdown")
|
||||
strong #{translate("lost_connection")}.
|
||||
|
|
|
@ -249,22 +249,25 @@ export default ConnectionManager = (function() {
|
|||
|
||||
// Site administrators can send the forceDisconnect event to all users
|
||||
|
||||
this.ide.socket.on('forceDisconnect', message => {
|
||||
this.ide.socket.on('forceDisconnect', (message, delay = 10) => {
|
||||
this.updateConnectionManagerState('inactive')
|
||||
this.shuttingDown = true // prevent reconnection attempts
|
||||
this.$scope.$apply(() => {
|
||||
this.$scope.permissions.write = false
|
||||
return (this.$scope.connection.forced_disconnect = true)
|
||||
})
|
||||
this.ide.socket.disconnect()
|
||||
this.ide.showGenericMessageModal(
|
||||
'Please Refresh',
|
||||
// flush changes before disconnecting
|
||||
this.ide.$scope.$broadcast('flush-changes')
|
||||
setTimeout(() => this.ide.socket.disconnect(), 1000)
|
||||
this.ide.showLockEditorMessageModal(
|
||||
'Please wait',
|
||||
`\
|
||||
We're performing maintenance on Overleaf and you need to refresh the editor.
|
||||
We're performing maintenance on Overleaf and you need to wait a moment.
|
||||
Sorry for any inconvenience.
|
||||
The editor will refresh in automatically in 10 seconds.\
|
||||
The editor will refresh automatically in ${delay} seconds.\
|
||||
`
|
||||
)
|
||||
return setTimeout(() => location.reload(), 10 * 1000)
|
||||
return setTimeout(() => location.reload(), delay * 1000)
|
||||
})
|
||||
|
||||
this.ide.socket.on('reconnectGracefully', () => {
|
||||
|
|
Loading…
Reference in a new issue