mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
add checkMongoConnect and checkRedisConnect funcs to grunt
This commit is contained in:
parent
5b0a6eb384
commit
192b77c573
2 changed files with 49 additions and 1 deletions
|
@ -8,6 +8,7 @@ knox = require "knox"
|
||||||
crypto = require "crypto"
|
crypto = require "crypto"
|
||||||
async = require "async"
|
async = require "async"
|
||||||
settings = require("settings-sharelatex")
|
settings = require("settings-sharelatex")
|
||||||
|
_ = require("underscore")
|
||||||
|
|
||||||
|
|
||||||
SERVICES = require("./config/services")
|
SERVICES = require("./config/services")
|
||||||
|
@ -101,7 +102,7 @@ module.exports = (grunt) ->
|
||||||
grunt.registerTask 'default', 'run'
|
grunt.registerTask 'default', 'run'
|
||||||
|
|
||||||
grunt.registerTask "check:redis", "Check that redis is installed and running", () ->
|
grunt.registerTask "check:redis", "Check that redis is installed and running", () ->
|
||||||
Helpers.checkRedis @async()
|
Helpers.checkRedisConnect @async()
|
||||||
grunt.registerTask "check:latexmk", "Check that latexmk is installed", () ->
|
grunt.registerTask "check:latexmk", "Check that latexmk is installed", () ->
|
||||||
Helpers.checkLatexmk @async()
|
Helpers.checkLatexmk @async()
|
||||||
grunt.registerTask "check:s3", "Check that Amazon S3 credentials are configured", () ->
|
grunt.registerTask "check:s3", "Check that Amazon S3 credentials are configured", () ->
|
||||||
|
@ -113,6 +114,9 @@ module.exports = (grunt) ->
|
||||||
grunt.registerTask "check:make", "Check that make is installed", () ->
|
grunt.registerTask "check:make", "Check that make is installed", () ->
|
||||||
Helpers.checkMake @async()
|
Helpers.checkMake @async()
|
||||||
|
|
||||||
|
grunt.registerTask "check:mongo", "Check that make is installed", () ->
|
||||||
|
Helpers.checkMongoConnect @async()
|
||||||
|
|
||||||
grunt.registerTask "check", "Check that you have the required dependencies installed", ["check:redis", "check:latexmk", "check:s3", "check:fs", "check:aspell"]
|
grunt.registerTask "check", "Check that you have the required dependencies installed", ["check:redis", "check:latexmk", "check:s3", "check:fs", "check:aspell"]
|
||||||
|
|
||||||
|
|
||||||
|
@ -347,3 +351,46 @@ module.exports = (grunt) ->
|
||||||
grunt.log.write "OK."
|
grunt.log.write "OK."
|
||||||
return callback()
|
return callback()
|
||||||
|
|
||||||
|
|
||||||
|
checkMongoConnect: (callback = (error) ->) ->
|
||||||
|
grunt.log.write "Checking can connect to mongo"
|
||||||
|
mongojs = require("mongojs")
|
||||||
|
db = mongojs.connect(settings.mongo.url, ["tags"])
|
||||||
|
db.runCommand { ping: 1 }, (err, res) ->
|
||||||
|
if !err and res.ok
|
||||||
|
grunt.log.write "OK."
|
||||||
|
return callback()
|
||||||
|
db.on 'error', (err)->
|
||||||
|
err = "Can not connect to mongodb"
|
||||||
|
grunt.log.error "FAIL."
|
||||||
|
grunt.log.errorlns """
|
||||||
|
|
||||||
|
ShareLaTeX can not talk to the mongdb instance
|
||||||
|
|
||||||
|
Check the mongodb instance is running and accessible on env var SHARELATEX_MONGO_URL
|
||||||
|
|
||||||
|
"""
|
||||||
|
return callback(err)
|
||||||
|
|
||||||
|
checkRedisConnect: (callback = (error) ->) ->
|
||||||
|
grunt.log.write "Checking can connect to redis\n"
|
||||||
|
rclient = require("redis").createClient(settings.redis.web)
|
||||||
|
|
||||||
|
rclient.ping (err, res) ->
|
||||||
|
if !err?
|
||||||
|
grunt.log.write "OK."
|
||||||
|
else
|
||||||
|
throw new Error("hllll")
|
||||||
|
return callback()
|
||||||
|
errorHandler = _.once (err)->
|
||||||
|
err = "Can not connect to redis"
|
||||||
|
grunt.log.error "FAIL."
|
||||||
|
grunt.log.errorlns """
|
||||||
|
|
||||||
|
ShareLaTeX can not talk to the redis instance
|
||||||
|
|
||||||
|
Check the redis instance is running and accessible on env var SHARELATEX_REDIS_URL
|
||||||
|
|
||||||
|
"""
|
||||||
|
return callback(err)
|
||||||
|
rclient.on 'error', errorHandler
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
"load-grunt-config": "^0.19.2",
|
"load-grunt-config": "^0.19.2",
|
||||||
"lodash": "^3.0.0",
|
"lodash": "^3.0.0",
|
||||||
"mongojs": "^0.18.1",
|
"mongojs": "^0.18.1",
|
||||||
|
"redis": "^2.6.2",
|
||||||
"rimraf": "~2.2.6",
|
"rimraf": "~2.2.6",
|
||||||
"settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git",
|
"settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git",
|
||||||
"underscore": "^1.7.0"
|
"underscore": "^1.7.0"
|
||||||
|
|
Loading…
Reference in a new issue