Skip to content

Config #2

@groundwater

Description

@groundwater

Okay @EndangeredMassa let's talk config. I brought it up in #1 but want to give it a proper treatment here.

Modules that exposes services via a start script may need to start differently on different hosts. The clearest example is a webapp that requires a database connection. You cannot assume the database will exist at 127.0.0.1, it may be on another host or have a non-standard port. Heroku handles this by passing in configuration as environment variables.

I think the environment-variable style is good and familiar to people, so I'm going to keep using it. Init can easily handle this approach, you pass init a json stanza describing environment variables to pass to the child process. Easy! This also keeps init free from making assumptions about how packages should be run. In fact, init knows nothing about node modules at all. It's the npkg command that interprets the package.json file in a module, and turns that into a daemon.

I am fairly convinced that npkg is the right place to decide what environment variables to pass to init. I see two options here:

  1. a command line option

    npkg start -e myapp.json webapp
    
  2. a standardized location for config files (e.g. $HOME/etc/npkg/myapp.json) when running npkg start myapp.

There is a third option, which I do not think is the right way to go, which is to do some complicated logic to determine what environment variables to pass in. I'd rather not bake that logic into npkg, it should just blindly pass in environment variables.

defining environment variable config files

There are some environment variables I would like to standardize on passing into services, such as TMPDIR and VARDIR. Also, if a module requires an environment variable such as MYSQL_URL, we should start documenting those in package.json.

I would love for another tool to generate the default config, and to keep npkg free from dealing with config logic, but I'm also trying to make sure services are suuuuuper simple to install and run. I'm still debating what to do in my head, and am still undecided on option (1) or option (2).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions