Allow config path from FOURTH_CONFIG
This commit is contained in:
parent
754a5af794
commit
bff92738d5
@ -35,7 +35,7 @@ Or you can download binary file form the Release page.
|
|||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Fourth will read yaml format configuration file from `/etc/fourth/config.yaml`, here is an minimal viable example:
|
Fourth will read yaml format configuration file from `/etc/fourth/config.yaml`, and you can set custom path to environment variable `FOURTH_CONFIG`, here is an minimal viable example:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
version: 1
|
version: 1
|
||||||
|
@ -37,7 +37,7 @@ $ cargo install fourth
|
|||||||
|
|
||||||
## 配置
|
## 配置
|
||||||
|
|
||||||
Fourth使用yaml格式的配置文件,默认情况下会读取`/etc/fourth/config.yaml`,如下是一个最小有效配置:
|
Fourth使用yaml格式的配置文件,默认情况下会读取`/etc/fourth/config.yaml`,您也可以设置自定义路径到环境变量`FOURTH_CONFIG`,如下是一个最小有效配置:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
version: 1
|
version: 1
|
||||||
|
@ -5,10 +5,13 @@ mod servers;
|
|||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::servers::Server;
|
use crate::servers::Server;
|
||||||
|
|
||||||
|
use std::env;
|
||||||
use log::{debug, error};
|
use log::{debug, error};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let config = match Config::new("/etc/fourth/config.yaml") {
|
let config_path = env::var("FOURTH_CONFIG").unwrap_or_else(|_| "/etc/fourth/config.yaml".to_string());
|
||||||
|
|
||||||
|
let config = match Config::new(&config_path) {
|
||||||
Ok(config) => config,
|
Ok(config) => config,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Could not load config: {:?}", e);
|
println!("Could not load config: {:?}", e);
|
||||||
|
Loading…
Reference in New Issue
Block a user