SaitoTech / saito-rust

A high-performance (reference) implementation of Saito in Rust
42 stars 10 forks source link

More Configuration Options If Config File Not Found In Default Location #345

Open owenkellogg opened 2 years ago

owenkellogg commented 2 years ago

Currently running saito requires that there be a configuration file present under the current directory/configuration however this may not match realistic expectations when running saito in production. When executing the saito binary from a different directory it panics with thread 'main' panicked at 'Failed to read configuration.: configuration file "/Users/zyler/github/saito-live/configuration/base" not found', /Users/zyler/github/saito-live/saito-rust/src/consensus.rs:136:44

Options for handling this gracefully would be:

1) Sane defaults without a configuration file

2) Allow path to configuration file to be specified via command line ie saito --config=/path/to/config.yml or via environment variable ie $SAITO_CONFIG_PATH

3) If file not found search for configuration in a user-standard directory such as $HOME/.saito

4) If user config directory is not found search in os-specific config path for instance /etc/saito on linux

This error I encountered when using homebrew to install saito on my mac, and realized the node operator onboarding experience could be improved with better configuration options.

(https://github.com/saito-live/homebrew-saito to try installation via homebrew on mac.)

thaodt commented 2 years ago

hi @stevenzeiler thank for pointing this out. This issue was fixed in a branch and still didn't get merged, however we're planning a big restructure for our codebase. In the meantime, if you want to correct it yourself, you may want to check this branch. But as I said, this branch's still under development.

owenkellogg commented 2 years ago

Great thanks thaodt I will check out that branch.

mat888 commented 2 years ago

Running into the same issue. Attempting to run saito_rust on the suggested branch with the boilerplate configuration files yielded as per @thaodt 's recommendation yielded:

mw@system:~/saito-rust$ git checkout remotes/origin/network_refactor_david2
mw@system:~/saito-rust$ git branch
* (HEAD detached at origin/network_refactor_david2)
  main

mw@system:~/saito-rust/target/release$ ./saito_rust 
LOG LEVEL SET TO: info. To set log level use RUST_LOG=[trace, info, debug, warn, error]
thread 'main' panicked at 'Failed to read configuration.: invalid type: unit value, expected struct NetworkSettings', /home/user1/saito-rust/src/consensus.rs:136:44
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This is on a 64bit Debian Server.