|
|
@@ -30,7 +30,6 @@ const IMAGES = {
|
|
|
}
|
|
|
|
|
|
let previousConfig = ''
|
|
|
-let mongoIsInitialized = false
|
|
|
|
|
|
function readDockerComposeOverride() {
|
|
|
try {
|
|
|
@@ -245,42 +244,12 @@ app.post(
|
|
|
(req, res) => {
|
|
|
const { cmd } = req.params
|
|
|
const { args } = req.body
|
|
|
- if (['stop', 'down'].includes(cmd)) {
|
|
|
- mongoIsInitialized = false
|
|
|
- }
|
|
|
runDockerCompose(cmd, args, (error, stdout, stderr) => {
|
|
|
res.json({ error, stdout, stderr })
|
|
|
})
|
|
|
}
|
|
|
)
|
|
|
|
|
|
-function maybeMongoInit(mongoInit, callback) {
|
|
|
- if (!mongoInit) return callback()
|
|
|
- runDockerCompose(
|
|
|
- 'up',
|
|
|
- ['--detach', '--wait', 'mongo'],
|
|
|
- (error, stdout, stderr) => {
|
|
|
- if (error) return callback(error, stdout, stderr)
|
|
|
-
|
|
|
- runDockerCompose(
|
|
|
- 'exec',
|
|
|
- [
|
|
|
- 'mongo',
|
|
|
- 'mongo',
|
|
|
- '--eval',
|
|
|
- 'rs.initiate({ _id: "overleaf", members: [ { _id: 0, host: "mongo:27017" } ] })',
|
|
|
- ],
|
|
|
- (error, stdout, stderr) => {
|
|
|
- if (!error) {
|
|
|
- mongoIsInitialized = true
|
|
|
- }
|
|
|
- callback(error, stdout, stderr)
|
|
|
- }
|
|
|
- )
|
|
|
- }
|
|
|
- )
|
|
|
-}
|
|
|
-
|
|
|
function maybeResetData(resetData, callback) {
|
|
|
if (!resetData) return callback()
|
|
|
|
|
|
@@ -297,7 +266,6 @@ function maybeResetData(resetData, callback) {
|
|
|
}
|
|
|
|
|
|
previousConfig = ''
|
|
|
- mongoIsInitialized = false
|
|
|
runDockerCompose(
|
|
|
'down',
|
|
|
['--timeout=0', '--volumes', 'mongo', 'redis'],
|
|
|
@@ -332,18 +300,16 @@ app.post(
|
|
|
return res.json({ error })
|
|
|
}
|
|
|
|
|
|
- maybeMongoInit(!mongoIsInitialized, (error, stdout, stderr) => {
|
|
|
- if (error) return res.json({ error, stdout, stderr })
|
|
|
- runDockerCompose(
|
|
|
- 'up',
|
|
|
- ['--detach', '--wait', 'sharelatex'],
|
|
|
- (error, stdout, stderr) => {
|
|
|
- const previousConfigServer = previousConfig
|
|
|
- previousConfig = JSON.stringify(req.body)
|
|
|
- res.json({ error, stdout, stderr, previousConfigServer })
|
|
|
- }
|
|
|
- )
|
|
|
- })
|
|
|
+ if (error) return res.json({ error, stdout, stderr })
|
|
|
+ runDockerCompose(
|
|
|
+ 'up',
|
|
|
+ ['--detach', '--wait', 'sharelatex'],
|
|
|
+ (error, stdout, stderr) => {
|
|
|
+ const previousConfigServer = previousConfig
|
|
|
+ previousConfig = JSON.stringify(req.body)
|
|
|
+ res.json({ error, stdout, stderr, previousConfigServer })
|
|
|
+ }
|
|
|
+ )
|
|
|
})
|
|
|
}
|
|
|
)
|
|
|
@@ -362,12 +328,4 @@ app.use(handleValidationErrors())
|
|
|
|
|
|
purgeDataDir()
|
|
|
|
|
|
-// Init on startup
|
|
|
-maybeMongoInit(true, err => {
|
|
|
- if (err) {
|
|
|
- console.error('mongo init failed', err)
|
|
|
- process.exit(1)
|
|
|
- }
|
|
|
-
|
|
|
- app.listen(80)
|
|
|
-})
|
|
|
+app.listen(80)
|