-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add support for configuration via file/stdin #63
Comments
👍 i think it should be as simple as trying to read stdin, and ignoring any command line options if data exists |
See #35 for a discussion on configuration flags precisely! |
or we can simply pass the config file as argument, better than reading from stdin. |
I'm good with this approach |
yeah, fine by me. makes reproducibility easier too. |
we should add, one of the motivating factors behind this was wanting to easily add lists (i.e. how we already do bootstrap nodes) and eventually add listen addresses to the configuration |
If the configuration becomes too complex to represent with flags (😢 ), consider the merits of libp2p/go-libp2p#526. If you're able to represent your configuration as a tree (explicit configuration structs with appropriate embedding), you can marshal the root of your configuration type to and from your configuration file format of choice (JSON/yaml etc.).
Ultimately lists lack the structure to represent complex configuration. Maybe nip it in the bud before it gets out of hand? |
It looks like @jacobheun already essentially suggested this, but libp2p/go-libp2p#526 does add some context. It would be unfortunate to reexport a bunch of config in other packages in this way when they could be exposing it like that already. |
interesting. the daemon ultimately has a different set of configuration options, but we are heavily leaning towards reading it from a JSON file. |
But it'd also mean introducing a dependency on the filesystem. We'd make one-off invocations slightly more concise, but virtualization and automation more-than-slightly more involved. But well I guess we can also have both As long as we make sure not to require stuff in the filesystem (apart from the control socket obviously, but that's not something the user needs to create themselves). Another approach not mentioned here yet is to configure the daemon over its own API. Disclaimer: I'm not yet very familiar with the daemon, or with all the teams that already have a need for the daemon (and it offering complex functionality). That need is there right now, so it's good to make small, swift, pragmatic steps. All I'd ask is we do steps that are in line with an overall longterm design goal and don't push ourselves into a corner that we eventually don't get out of. Things that trigger me: big config structs, god objects, long lists of cli flags, (bidirectionally) leaking abstractions between UIs and "business" code :P There'd be a command running the daemon (let's say The handling of the user interface (CLI (and config file)) would be nicely confined to one command and decoupled from the actual work. We can focus mainly on API design instead. There's probably even a named design pattern for this. Most importantly it'd help much on the way towards hot-reloading, which I think is super-desirable for anything networking-focused. Long way to get there, but very desirable, and as we get more networky down the roadmap, networking people will expect it. It'll require pretty hefty design and refactoring work, but if we're going to refactor Host/Swarm in Go anyway... Don't need to have 100% hot-reloading ability right away, can do it step by step. |
Exactly my thoughts. I'm not sure if Anyway, it should be trivial to support both inputs, and agree it's the best path forward.
I'd shy away from watching the file and hot-reloading when it changes. It creates a significant security hole, and also it's not very polite. I'd propose reacting to |
Yeah sounds good, or -f/-i (-o sounds like output)
Agree on not watching the file and handling a signal instead, but SIGHUP or SIGUSR1 are most common for reloading. I've only ever seen SIGSTOP used for log rotation (in combination with SIGCONT), I think the process doesn't even get it (same as SIGKILL). |
Also, as it is a config, maybe just go with |
As the daemon grows our configuration flag options are likely to become cumbersome pretty quickly. I was talking with @bigs and @vasco-santos about needing to add support for specifying the multiaddrs the daemons libp2p node listens on. We could, and probably should, add a comma delimited string flag similar to how we add bootstrap addresses. Over time though, reading through all of the flags you have enabled for a node could get overwhelming.
I'd like to propose adding support for piping a config file to the daemon. For example:
$ cat config.json | p2p daemon
This would also have the nice benefit of being able to have node type configurations pre made for users; DHT booster, relay, rendezvous, etc.
If this sounds good, I can write up a spec for the json configuration.
The text was updated successfully, but these errors were encountered: