Skip to content

Allow service to start without config file #16

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

Open
tpo opened this issue Apr 16, 2025 · 3 comments
Open

Allow service to start without config file #16

tpo opened this issue Apr 16, 2025 · 3 comments

Comments

@tpo
Copy link
Member

tpo commented Apr 16, 2025

If the service gets started without a config file:

docker run -ti sourcepole/qwc-ldap-auth

then it will report an error:

[2025-04-16 09:05:33,979] ERROR in runtime_config: Could not load runtime config '/srv/qwc_service/config/default/ldapAuthConfig.json':
[Errno 2] No such file or directory: '/srv/qwc_service/config/default/ldapAuthConfig.json'

Is that a problem?

If not, then I propose to transform the ERROR into an INFO log message. Do you concur?

Note to self: this fixes the error:

$ cat ./ldapAuthConfig.json 
{
  "$schema": "https://github.com/qwc-services/qwc-ldap-auth/raw/master/schemas/qwc-ldap-auth.json",
  "service": "ldap-auth",
  "config": {
  }
}
$ docker run -ti  --mount type=bind,src=./ldapAuthConfig.json,dst=/srv/qwc_service/config/default/ldapAuthConfig.json sourcepole/qwc-ldap-auth
@tpo
Copy link
Member Author

tpo commented Apr 16, 2025

Here I'd suggest:

config_handler = RuntimeConfig("ldapAuth", app.logger)

to add an option:

config_handler = RuntimeConfig("ldapAuth", app.logger, config_file_is_optional=true)

An implementation of this proposal on the qwc-services-core's side can be found in qwc-services/qwc-services-core#20

@manisandro
Copy link
Member

One thought is that there is a bit of a risk of introducing heterogeneity throughout the QWC services: currently all expect a config file to exist and (at least if schema validation is enabled in the config generator) expect the config to conform to the respective schema. I guess the use-case here is to control the settings through Envs and not though the json config, but is it really required to use Envs here rather than just using the config?

@tpo
Copy link
Member Author

tpo commented Apr 16, 2025

One thought is that there is a bit of a risk of introducing heterogeneity throughout the QWC services: currently all expect a config file to exist and (at least if schema validation is enabled in the config generator) expect the config to conform to the respective schema. I guess the use-case here is to control the settings through Envs and not though the json config, but is it really required to use Envs here rather than just using the config?

I agree. As far as I understand there is no reason to configure the service via environment variables. It could just as well be configured via the config file.

I guess the service gets configured by ENV variables now for historical reasons - it got done that way a long time ago before qwc-services had a coherent structure.

So it could just as well get configured via the config file. If that is the way forward then everybody upgrading their existing qwc-ldap-service will need to move their current ENV based configuration into a config file.

What do you think @pka ?

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