Skip to content

Commit

Permalink
Read redis host from env.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cloud10240 committed Nov 14, 2023
1 parent 346bea0 commit 23bebcb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use env_logger::Env;
use redis::Commands;
use reqwest::Url;
use serde_json::{json, Value};
use std::env;

use crate::cli::Cli;
use crate::rpc_cache_handler::RpcCacheHandler;
Expand All @@ -17,7 +18,11 @@ mod cli;
mod rpc_cache_handler;

lazy_static! {
static ref REDIS: redis::Client = redis::Client::open("redis://localhost/").unwrap();
static ref REDIS: redis::Client = {
let redis_host = env::var("REDIS_HOST").unwrap_or_else(|_| "localhost".to_string());
let redis_url = format!("redis://{}", redis_host);
redis::Client::open(redis_url).expect("Failed to create Redis client")
};
}

struct ChainState {
Expand Down

0 comments on commit 23bebcb

Please sign in to comment.