Hi,

I’m asking for opinions and preferences.

There is no right or wrong.

Scenario:

I have a tool (server component, api only, no gui) that has a config file and no per-user adjustable things. The admin can change things, of course.

Now the tool gets plugins, where to configure them?

  1. All in one config file with plugins having a section for their things,
  2. plugins get their own config file.
  3. the main config points to a storage (database) with config options for everything, a kind of variant of 1.
  4. something else/better

Hoping for a civil discussion ;)

Cheers

Grumpy

  • dohpaz42@lemmy.world
    link
    fedilink
    English
    arrow-up
    3
    ·
    4 months ago

    I like how Symfony does it in PHP:

    Config files have well known locations (e.g., <project root>/config for main project, and <plugin root>/Resources/config for plugins) for config files. The main config is loaded into memory, and then each plugin config is loaded and merged into the main config.

    This has several advantages:

    1. Each path allows for auto-discovery of new config files
    2. The config files can be in any file format that the app supports read (e.g., .ini, .yaml, . php, etc)
    3. The plugin config can overwrite anything in the main config
    4. Environment-specific configs can be loaded based on a $ENV variable (e.g., dev or test), or by ignoring files in your VCS

    For Symfony, it is more complicated than that in that they also have mechanisms to define valid configuration values and their expected types, but that’s beyond the scope of your question.


    Database configuration is an interesting choice. It certainly would help with scaling across multiple servers. Of course there is still a need for local configuration to access the database, but how often does that really change? But if you don’t need to scale more than two or three servers, it might be a bit of overkill IMO.