Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vatican-conf.json #31

Open
smart--petea opened this issue Oct 1, 2014 · 2 comments
Open

vatican-conf.json #31

smart--petea opened this issue Oct 1, 2014 · 2 comments

Comments

@smart--petea
Copy link
Contributor

There can be the situation then same vatican-conf.json must be shared between some vatican instances (each in different directory).

For this case will be good (like issue #26) to use

  1. absolute path for context
  2. offer a variable for path of vatican-conf.json (if absolute - ok, if relative then will be relative to context)

At this time constructor of Vatican looks like

function Vatican(options) {
...
    config = (options) ? options : require(CONFIG_FILE_PATH);
...
    this.options = _.defaults( config, DEFAULT_CONFIG);
...
}

and has a very rigid behaviour (from options point of view) because in options can be fields that are not in config and fields that are not in options.

Maybe to define a new options.config which can match one of the cases

  1. if is undefined then config will be read relative to current context
  2. if is false then config will be not read (considered equal to {})
  3. is relative path
  4. is absolute path
    and has less priority compared to options
this.options = _.defaults(options, config, DEFAULT_CONFIG);
@deleteman
Copy link
Owner

@smart--petea I'm not sure I understand the issue here.

  • For starters, the vatican-conf.json file is loaded from the root directory of the project. This path can't be changed. So how would several projects share the same config file?
  • Also, assume they do, if the config file is present, then all projects will share the same configuration, including port number, which will cause conflicts.

The best solution for this scenario, would be to have a custom json file, with the shared configuration values, and then, each project would load that json, add the custom config values (like port) and then pass that new json to Vatican's constructor.

Something like this:

var vat = require("vatican");
var genericConfig = require("../shared-folder/config.json")
genericConfig.port = 2000 ///each project would customize this attribute
var app = new vat(genericConfig);
//....

@smart--petea
Copy link
Contributor Author

I previously mention that if application will be run from one folder which is not intended by developer as root folder then process.cwd will not point correctly to root folder. Such cases can be

  1. application is started by cron
  2. application is started by something like node /path/index.js

Why do not let to user to use at the same time the options and config? This is flexibile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants