Skip to content

Commit

Permalink
comment in config.toml that the path of saved_state should be relative
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj authored and FlorentinDUBOIS committed Jul 13, 2022
1 parent 78272fc commit d9e008f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions bin/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# path to a file sozu can use to load an initial configuration state for its
# routing. You can generate this file from sozu's current routing by running
# the command `sozuctl state save -f state.json`
# this must be RELATIVE to config.toml
saved_state = "./state.json"

# save the configuration to the saved_state file every time we receive a
Expand Down
9 changes: 6 additions & 3 deletions command/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,10 @@ fn default_accept_queue_timeout() -> u32 {

impl Config {
pub fn load_from_path(path: &str) -> anyhow::Result<Config> {
let mut config = FileConfig::load_from_path(path).map(|config| config.into(path))?;
let file_config =
FileConfig::load_from_path(path).with_context(|| "Could not load the config file")?;

let mut config = file_config.into(path);

config.saved_state = config
.saved_state_path()
Expand Down Expand Up @@ -1289,7 +1292,7 @@ impl Config {
.with_context(|| "could not parse command socket path")
}

pub fn saved_state_path(&self) -> anyhow::Result<Option<String>> {
fn saved_state_path(&self) -> anyhow::Result<Option<String>> {
let path = match self.saved_state.as_ref() {
Some(path) => path,
None => return Ok(None),
Expand Down Expand Up @@ -1323,7 +1326,7 @@ impl Config {

let stringified_path = saved_state_path_raw
.to_str()
.ok_or(anyhow::Error::msg("Unvalid UTF8"))?
.ok_or(anyhow::Error::msg("Unvalid character format, expected UTF8"))?
.to_string();

return Ok(Some(stringified_path));
Expand Down

0 comments on commit d9e008f

Please sign in to comment.