[web] Support runtime configuration using commandline args + config file #1
No reviewers
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Emi/PronounsToday#1
Loading…
Reference in a new issue
No description provided.
Delete branch "configuration"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
run
anddump-statics
[not yet implemented])[lib]
changes to enable extra serialization/parsing functionalityI've left comments on things I think need changing.
@ -26,3 +29,3 @@
/// `UserPreferences` struct shares a lifetime with the settings it was created with.
#[non_exhaustive]
#[derive(Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
Import Serialize and Deserialize directly instead of qualifing.
Resolved in
6d087bd
@ -0,0 +54,4 @@
short = 'c'))]
/// path to the config file (generated if needed). Defaults to
/// /etc/pronouns_today.yml
pub config: String,
Don't use Strings for paths. Use PathBuf instead.
Resolved in
6d087bd
@ -0,0 +63,4 @@
#[argh(option, short = 'p')]
/// the port to listen on
pub port: Option<u16>,
The user should be able to specify a full socket address.
Resolved in
c6ba724
@ -0,0 +88,4 @@
match File::open(&self.config) {
Ok(raw_cfg) => {
serde_yaml::from_reader(raw_cfg)
.map_err(ConfigError::MalformedConfig)
This should maybe contain the serde error so we can print what was wrong in the config file.
A little confused here? This does wrap the serde error. See line 156
@ -0,0 +120,4 @@
pub instance_settings: InstanceSettings,
/// The port for the server to bind to. Defaults to 1312
pub port: u16,
Config should specify the full socket address, not just the port. It should also support multiple.
I think binding to multiple addresses might be a little bit beyond the scope of this PR at least. I'll add the ability to specify binding to a specific address though. I still think that even that might be slightly beyond scope of something that's primarily going to be used in docker containers and/or behind reverse proxies, but it's easy enough to add
@ -145,0 +167,4 @@
println!("A config file has been generated at {}! Please check it out
and modify it to your liking, and then run this command
again", path);
exit(0);
Maybe return an error here since there server didn't actually start.
Resolved in
6d087bd