diff --git a/libraries/settings/README.md b/libraries/settings/README.md new file mode 100644 index 0000000000..266092ba9c --- /dev/null +++ b/libraries/settings/README.md @@ -0,0 +1,19 @@ +settings-sharelatex +=================== + +A small module to allow global config settings to be set for all services +within the ShareLaTeX architecture. + +Settings file location +---------------------- + +You can specify a custom location for the settings file by setting the +`SHARELATEX_CONFIG` environment variable. E.g. + + $ export SHARELATEX_CONFIG=/home/james/config/settings.development.coffee + +Otherwise, the settings will be loaded from `config/settings.NODE_ENV.coffee`, +where `NODE_ENV` is another evnironment variable, or defaults to `development`. + +The config directory is first looked for in the current directory, and then relative +to the settings module directory. \ No newline at end of file diff --git a/libraries/settings/Settings.coffee b/libraries/settings/Settings.coffee index b60d6f8396..8f91b46403 100755 --- a/libraries/settings/Settings.coffee +++ b/libraries/settings/Settings.coffee @@ -2,10 +2,13 @@ fs = require "fs" path = require "path" env = (process.env.NODE_ENV or "development").toLowerCase() -possibleConfigFiles = [ - process.cwd() + "/config/settings.#{env}.coffee" - path.normalize(__dirname + "/../../config/settings.#{env}.coffee") -] +if process.env.SHARELATEX_CONFIG? + possibleConfigFiles = [process.env.SHARELATEX_CONFIG] +else + possibleConfigFiles = [ + process.cwd() + "/config/settings.#{env}.coffee" + path.normalize(__dirname + "/../../config/settings.#{env}.coffee") + ] for file in possibleConfigFiles if fs.existsSync(file)