mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
[CE/SP] Flush redis on docker stop
(#11714)
* [CE/SP] Flush redis on `docker stop` * Extracted `limit` to variable Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com> * Increased logging --------- Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com> GitOrigin-RevId: 4bcb4e70988337369acca0e80f243609bd6323ed
This commit is contained in:
parent
204e7a0c87
commit
909bb99b9f
6 changed files with 89 additions and 2 deletions
|
@ -52,9 +52,10 @@ ADD server-ce/cron /overleaf/cron
|
||||||
ADD server-ce/config/crontab-history /etc/cron.d/crontab-history
|
ADD server-ce/config/crontab-history /etc/cron.d/crontab-history
|
||||||
RUN chmod 600 /etc/cron.d/crontab-history
|
RUN chmod 600 /etc/cron.d/crontab-history
|
||||||
|
|
||||||
# Copy Phusion Image startup scripts to its location
|
# Copy Phusion Image startup and shutdown scripts to their locations
|
||||||
# --------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
COPY server-ce/init_scripts/ /etc/my_init.d/
|
COPY server-ce/init_scripts/ /etc/my_init.d/
|
||||||
|
COPY server-ce/init_preshutdown_scripts/ /etc/my_init.pre_shutdown.d/
|
||||||
|
|
||||||
# Copy app settings files
|
# Copy app settings files
|
||||||
# -----------------------
|
# -----------------------
|
||||||
|
|
11
server-ce/init_preshutdown_scripts/01_flush_project_history
Executable file
11
server-ce/init_preshutdown_scripts/01_flush_project_history
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd /overleaf/services/project-history && node scripts/flush_all.js >> /var/log/sharelatex/project-history.log 2>&1
|
||||||
|
|
||||||
|
EXIT_CODE="$?"
|
||||||
|
if [ $EXIT_CODE -ne 0 ]
|
||||||
|
then
|
||||||
|
echo "project-history/scripts/flush_all.js failed with exit code $EXIT_CODE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
11
server-ce/init_preshutdown_scripts/01_flush_track_changes
Executable file
11
server-ce/init_preshutdown_scripts/01_flush_track_changes
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd /overleaf/services/track-changes && node scripts/flush_all.js >> /var/log/sharelatex/track-changes.log 2>&1
|
||||||
|
|
||||||
|
EXIT_CODE="$?"
|
||||||
|
if [ $EXIT_CODE -ne 0 ]
|
||||||
|
then
|
||||||
|
echo "track-changes/scripts/flush_all.js failed with exit code $EXIT_CODE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
11
server-ce/init_preshutdown_scripts/02_flush_document_updater
Executable file
11
server-ce/init_preshutdown_scripts/02_flush_document_updater
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd /overleaf/services/document-updater && node scripts/flush_all.js >> /var/log/sharelatex/document-updater.log 2>&1
|
||||||
|
|
||||||
|
EXIT_CODE="$?"
|
||||||
|
if [ $EXIT_CODE -ne 0 ]
|
||||||
|
then
|
||||||
|
echo "document-updater/scripts/flush_all.js failed with exit code $EXIT_CODE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
28
services/document-updater/scripts/flush_all.js
Normal file
28
services/document-updater/scripts/flush_all.js
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
const ProjectFlusher = require('../app/js/ProjectFlusher')
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
console.log('Flushing all projects')
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const options = {
|
||||||
|
limit: 100000,
|
||||||
|
concurrency: 5,
|
||||||
|
}
|
||||||
|
ProjectFlusher.flushAllProjects(options, err => {
|
||||||
|
if (err) {
|
||||||
|
reject(err)
|
||||||
|
} else {
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
|
.then(() => {
|
||||||
|
console.log('Done flushing all projects')
|
||||||
|
process.exit(0)
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('There was an error flushing all projects', { error })
|
||||||
|
process.exit(1)
|
||||||
|
})
|
25
services/track-changes/scripts/flush_all.js
Normal file
25
services/track-changes/scripts/flush_all.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
const UpdatesManager = require('../app/js/UpdatesManager')
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const limit = -1
|
||||||
|
console.log('Flushing all updates')
|
||||||
|
UpdatesManager.flushAll(limit, err => {
|
||||||
|
if (err) {
|
||||||
|
reject(err)
|
||||||
|
} else {
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
|
.then(() => {
|
||||||
|
console.log('Done flushing all updates')
|
||||||
|
process.exit(0)
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('There was an error flushing updates', { error })
|
||||||
|
process.exit(1)
|
||||||
|
})
|
Loading…
Reference in a new issue