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

Allow initialization without config file #249

Open
HalosGhost opened this issue Sep 18, 2018 · 0 comments
Open

Allow initialization without config file #249

HalosGhost opened this issue Sep 18, 2018 · 0 comments

Comments

@HalosGhost
Copy link
Contributor

HalosGhost commented Sep 18, 2018

At the moment, there are two init functions:

  • lwan_init()
  • lwan_init_with_config()

As a side-note, the naming convention of these functions is somewhat confusing. The first function implicitly reads from a lwan configuration file (with the same name as the binary being run). The second allows you to pass a configuration struct, and therefore should allow for not needing a configuration file to be present.

Unfortunately, using lwan_init_with_config() does not escape the need for a configuration file. Lwan still requires a minimal config file when using this function, roughly:

listener *:8080 {}

Ideally, using lwan_init_with_config() should escape any need for a configuration file. Perhaps a configuration file, if one is present, should still be honored (though I am unsure if that's actually preferable), but it certainly should not be required.

It looks like the specific culprit here is try_setup_with_config() (reproduced below for ease):

static void try_setup_from_config(struct lwan *l, const struct lwan_config *config)
{
    if (!setup_from_config(l, config->config_file_path)) {
        if (config->config_file_path) {
            lwan_status_critical("Could not read config file: %s",
                                 config->config_file_path);
        }
    }

    /* `quiet` key might have changed value. */
    lwan_status_init(l);
}

I am hoping this can be modified such that if config != &default_config, it skips the check for the config file path. Does that sound reasonable? Are there any assumptions I am making which mean this needs to be done in a different way or that this cannot be done at all?

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

Successfully merging a pull request may close this issue.

1 participant