mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-25 15:51:04 +00: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,38 +224,63 @@ module.exports = (grunt) ->
|
|||
callback(error)
|
||||
|
||||
checkS3: (callback = (error) ->) ->
|
||||
grunt.log.write "Checking S3 credentials... "
|
||||
Settings = require "settings-sharelatex"
|
||||
try
|
||||
client = knox.createClient({
|
||||
key: Settings.s3.key
|
||||
secret: Settings.s3.secret
|
||||
bucket: Settings.s3.buckets.user_files
|
||||
})
|
||||
catch e
|
||||
grunt.log.error "FAIL."
|
||||
grunt.log.errorlns """
|
||||
Please configure you Amazon S3 credentials in config/settings.development.coffee
|
||||
|
||||
Amazon S3 (Simple Storage Service) is a cloud storage service provided by
|
||||
Amazon. ShareLaTeX uses S3 for storing binary files like images. You can
|
||||
sign up for an account and find out more at:
|
||||
|
||||
http://aws.amazon.com/s3/
|
||||
|
||||
"""
|
||||
return callback()
|
||||
|
||||
client.getFile "does-not-exist", (error, response) ->
|
||||
unless response? and response.statusCode == 404
|
||||
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.filestore.s3.key
|
||||
secret: Settings.filestore.s3.secret
|
||||
bucket: Settings.filestore.stores.user_files
|
||||
})
|
||||
catch e
|
||||
grunt.log.error "FAIL."
|
||||
grunt.log.errorlns """
|
||||
Could not connect to Amazon S3. Please check your credentials.
|
||||
Please configure you Amazon S3 credentials in config/settings.development.coffee
|
||||
|
||||
Amazon S3 (Simple Storage Service) is a cloud storage service provided by
|
||||
Amazon. ShareLaTeX uses S3 for storing binary files like images. You can
|
||||
sign up for an account and find out more at:
|
||||
|
||||
http://aws.amazon.com/s3/
|
||||
|
||||
"""
|
||||
else
|
||||
grunt.log.write "OK."
|
||||
return callback()
|
||||
client.getFile "does-not-exist", (error, response) ->
|
||||
unless response? and response.statusCode == 404
|
||||
grunt.log.error "FAIL."
|
||||
grunt.log.errorlns """
|
||||
Could not connect to Amazon S3. Please check your credentials.
|
||||
"""
|
||||
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... "
|
||||
exec "make --version", (error, stdout, stderr) ->
|
||||
|
|
|
@ -19,17 +19,31 @@ module.exports =
|
|||
# File storage
|
||||
# ------------
|
||||
#
|
||||
# ShareLaTeX stores binary files like images in S3.
|
||||
# Fill in your Amazon S3 credentials below.
|
||||
s3:
|
||||
key: ""
|
||||
secret: ""
|
||||
buckets:
|
||||
# The S3 bucket name to store binary files in
|
||||
user_files: ""
|
||||
# ShareLaTeX needs somewhere to store binary files like images.
|
||||
# There are currently two options:
|
||||
# Amazon S3 (the default)
|
||||
# local filesystem
|
||||
|
||||
# Tell the filestore api to use s3 to persist files, in future more backends can be added
|
||||
filestoreBackend: "s3"
|
||||
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: ""
|
||||
|
||||
# Databases
|
||||
# ---------
|
||||
|
|
Loading…
Reference in a new issue