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

Feature request, Multiple env files for a single service #183

Closed
hongkongkiwi opened this issue Aug 18, 2021 · 6 comments
Closed

Feature request, Multiple env files for a single service #183

hongkongkiwi opened this issue Aug 18, 2021 · 6 comments
Milestone

Comments

@hongkongkiwi
Copy link
Contributor

hongkongkiwi commented Aug 18, 2021

Hi there,

I'm building a system which has env files for each service stored in /etc/default/<service>

I would like to allow users to override variables using a read-write directory, so for example something like /mnt/flash/etc/default/<service>

So, I would like to be able to read multiple env files. For example:
env:-/etc/default/foo,/mnt/flash/etc/default/foo

This way, we require that /etc/default/foo exists and this provides our hardcoded variables. However, after reading that, /mnt/flash/etc/default/foo is read and if the variable has the same name.... e.g. FOO_OPTIONS then it would just overwrite as the variable files would be read in order of left to right.

This means the user can optionally create a /mnt/flash/etc/default/foo file and overwrite some (or all) of the variables. I was thinking we could have the same format, so this would also be valid if we wanted it to error if flash env doesn't exist:
env:-/etc/default/foo,-/mnt/flash/etc/default/foo

Would it be possible to add this feature? The only way right now I think to do this is to use a script to call my service which is less than ideal.

@hongkongkiwi hongkongkiwi changed the title Multiple env files for a single service [Suggestion] Multiple env files for a single service Aug 19, 2021
@troglobit
Copy link
Owner

Anything's possible, but I have no need for this myself, and it would require quite a lot of work to change current data structures and inotify watchers to handle.

I'm saving this but putting it on milestone future. Maybe someone else wants it too and can do the leg work.

@troglobit troglobit added this to the FUTURE milestone Aug 19, 2021
@hongkongkiwi hongkongkiwi changed the title [Suggestion] Multiple env files for a single service Feature request, Multiple env files for a single service Aug 22, 2021
@hongkongkiwi
Copy link
Contributor Author

Thanks for considering.

In the meantime, I'll source env1 in finit.conf then call a script which first sources a subsequent env file, then exec the app. I think it can be a reasonable workaround.

@hongkongkiwi
Copy link
Contributor Author

hongkongkiwi commented Feb 9, 2022

As another simple idea, could we have a default-env:"/etc/default/my.env" extra and then no need to change the way env:"/mnt/flash/my.env" works.

@troglobit
Copy link
Owner

The problem is that the env files are considered part of the configuration of that service, so when either the env file or the .conf file changes, Finit registers this and knows which services to restart/SIGHUP when it receives initctl reload. So either way it's a lot of work and I'd rather have a uniform concept that worked for more use-cases.

@hongkongkiwi
Copy link
Contributor Author

hongkongkiwi commented Apr 28, 2022

I think this can actually work already when #248 is implemented.

if an additional env file is required (such as in my case) it can be sourced in the pre script.

@troglobit
Copy link
Owner

True, thanks for following-up on this!

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