mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
refactor config settings.
This commit is contained in:
parent
88bd359209
commit
4196e823ab
2 changed files with 78 additions and 37 deletions
|
@ -104,9 +104,11 @@ module.exports = (grunt) ->
|
||||||
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", () ->
|
||||||
Helpers.checkS3 @async()
|
Helpers.checkS3 @async()
|
||||||
|
grunt.registerTask "check:fs", "Check that local filesystem options are configured", () ->
|
||||||
|
Helpers.checkFS @async()
|
||||||
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", "Check that you have the required dependencies installed", ["check:redis", "check:latexmk", "check:s3"]
|
grunt.registerTask "check", "Check that you have the required dependencies installed", ["check:redis", "check:latexmk", "check:s3", "check:fs"]
|
||||||
|
|
||||||
Helpers =
|
Helpers =
|
||||||
installService: (repo_src, dir, callback = (error) ->) ->
|
installService: (repo_src, dir, callback = (error) ->) ->
|
||||||
|
@ -222,13 +224,17 @@ module.exports = (grunt) ->
|
||||||
callback(error)
|
callback(error)
|
||||||
|
|
||||||
checkS3: (callback = (error) ->) ->
|
checkS3: (callback = (error) ->) ->
|
||||||
grunt.log.write "Checking S3 credentials... "
|
|
||||||
Settings = require "settings-sharelatex"
|
Settings = require "settings-sharelatex"
|
||||||
|
if Settings.filestore.backend==""
|
||||||
|
grunt.log.writeln "No backend specified. Assuming Amazon S3"
|
||||||
|
Settings.filestore.backend = "s3"
|
||||||
|
if Settings.filestore.backend=="s3"
|
||||||
|
grunt.log.write "Checking S3 credentials... "
|
||||||
try
|
try
|
||||||
client = knox.createClient({
|
client = knox.createClient({
|
||||||
key: Settings.s3.key
|
key: Settings.filestore.s3.key
|
||||||
secret: Settings.s3.secret
|
secret: Settings.filestore.s3.secret
|
||||||
bucket: Settings.s3.buckets.user_files
|
bucket: Settings.filestore.stores.user_files
|
||||||
})
|
})
|
||||||
catch e
|
catch e
|
||||||
grunt.log.error "FAIL."
|
grunt.log.error "FAIL."
|
||||||
|
@ -243,7 +249,6 @@ module.exports = (grunt) ->
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return callback()
|
return callback()
|
||||||
|
|
||||||
client.getFile "does-not-exist", (error, response) ->
|
client.getFile "does-not-exist", (error, response) ->
|
||||||
unless response? and response.statusCode == 404
|
unless response? and response.statusCode == 404
|
||||||
grunt.log.error "FAIL."
|
grunt.log.error "FAIL."
|
||||||
|
@ -253,6 +258,28 @@ module.exports = (grunt) ->
|
||||||
else
|
else
|
||||||
grunt.log.write "OK."
|
grunt.log.write "OK."
|
||||||
callback()
|
callback()
|
||||||
|
else
|
||||||
|
grunt.log.writeln "Filestore other than S3 configured. Not checking S3."
|
||||||
|
callback()
|
||||||
|
|
||||||
|
checkFS: (callback = (error) ->) ->
|
||||||
|
Settings = require "settings-sharelatex"
|
||||||
|
if Settings.filestore.backend=="fs"
|
||||||
|
grunt.log.write "Checking FS configuration..."
|
||||||
|
fs = require("fs")
|
||||||
|
fs.exists Settings.filestore.stores.user_files, (exists) ->
|
||||||
|
if exists
|
||||||
|
grunt.log.write "OK."
|
||||||
|
else
|
||||||
|
grunt.log.error "FAIL."
|
||||||
|
grunt.log.errorlns """
|
||||||
|
Could not find directory "#{Settings.filestore.stores.user_files}".
|
||||||
|
Please check your configuration.
|
||||||
|
"""
|
||||||
|
else
|
||||||
|
grunt.log.writeln "Filestore other than FS configured. Not checking FS."
|
||||||
|
callback()
|
||||||
|
|
||||||
|
|
||||||
checkMake: (callback = (error) ->) ->
|
checkMake: (callback = (error) ->) ->
|
||||||
grunt.log.write "Checking make is installed... "
|
grunt.log.write "Checking make is installed... "
|
||||||
|
|
|
@ -19,17 +19,31 @@ module.exports =
|
||||||
# File storage
|
# File storage
|
||||||
# ------------
|
# ------------
|
||||||
#
|
#
|
||||||
# ShareLaTeX stores binary files like images in S3.
|
# ShareLaTeX needs somewhere to store binary files like images.
|
||||||
# Fill in your Amazon S3 credentials below.
|
# There are currently two options:
|
||||||
|
# Amazon S3 (the default)
|
||||||
|
# local filesystem
|
||||||
|
|
||||||
|
filestore:
|
||||||
|
# which backend persistor to use.
|
||||||
|
# choices are
|
||||||
|
# s3 - Amazon S3
|
||||||
|
# fs - local filesystem
|
||||||
|
backend: "s3"
|
||||||
|
stores:
|
||||||
|
# where to store user and template binary files
|
||||||
|
#
|
||||||
|
# For Amazon S3 this is the bucket name to store binary files in
|
||||||
|
# Must contain full url like: <bucketname>.s3.amazonaws.com
|
||||||
|
#
|
||||||
|
# For local filesystem this is the directory to store the files in.
|
||||||
|
# Must contain full path, e.g. "/var/lib/sharelatex/data"
|
||||||
|
# This path must exist, not be tmpfs and be writable to by the user sharelatex is run as.
|
||||||
|
user_files: ""
|
||||||
s3:
|
s3:
|
||||||
|
# if you are using S3, then fill in your S3 details below
|
||||||
key: ""
|
key: ""
|
||||||
secret: ""
|
secret: ""
|
||||||
buckets:
|
|
||||||
# The S3 bucket name to store binary files in
|
|
||||||
user_files: ""
|
|
||||||
|
|
||||||
# Tell the filestore api to use s3 to persist files, in future more backends can be added
|
|
||||||
filestoreBackend: "s3"
|
|
||||||
|
|
||||||
# Databases
|
# Databases
|
||||||
# ---------
|
# ---------
|
||||||
|
|
Loading…
Reference in a new issue