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()
|
||||
grunt.registerTask "check:s3", "Check that Amazon S3 credentials are configured", () ->
|
||||
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", () ->
|
||||
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 =
|
||||
installService: (repo_src, dir, callback = (error) ->) ->
|
||||
|
@ -222,13 +224,17 @@ module.exports = (grunt) ->
|
|||
callback(error)
|
||||
|
||||
checkS3: (callback = (error) ->) ->
|
||||
grunt.log.write "Checking S3 credentials... "
|
||||
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
|
||||
client = knox.createClient({
|
||||
key: Settings.s3.key
|
||||
secret: Settings.s3.secret
|
||||
bucket: Settings.s3.buckets.user_files
|
||||
key: Settings.filestore.s3.key
|
||||
secret: Settings.filestore.s3.secret
|
||||
bucket: Settings.filestore.stores.user_files
|
||||
})
|
||||
catch e
|
||||
grunt.log.error "FAIL."
|
||||
|
@ -243,7 +249,6 @@ module.exports = (grunt) ->
|
|||
|
||||
"""
|
||||
return callback()
|
||||
|
||||
client.getFile "does-not-exist", (error, response) ->
|
||||
unless response? and response.statusCode == 404
|
||||
grunt.log.error "FAIL."
|
||||
|
@ -253,6 +258,28 @@ module.exports = (grunt) ->
|
|||
else
|
||||
grunt.log.write "OK."
|
||||
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) ->) ->
|
||||
grunt.log.write "Checking make is installed... "
|
||||
|
|
|
@ -19,17 +19,31 @@ module.exports =
|
|||
# File storage
|
||||
# ------------
|
||||
#
|
||||
# ShareLaTeX stores binary files like images in S3.
|
||||
# Fill in your Amazon S3 credentials below.
|
||||
# ShareLaTeX needs somewhere to store binary files like images.
|
||||
# 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:
|
||||
# if you are using S3, then fill in your S3 details below
|
||||
key: ""
|
||||
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
|
||||
# ---------
|
||||
|
|
Loading…
Reference in a new issue