diff --git a/coordinator/src/main.rs b/coordinator/src/main.rs index 0f75c733..56aed81a 100644 --- a/coordinator/src/main.rs +++ b/coordinator/src/main.rs @@ -679,7 +679,7 @@ async fn main() { let key = Zeroizing::new(::F::ZERO); // TODO let p2p = LocalP2p::new(1).swap_remove(0); // TODO - let processors = Arc::new(MessageQueue::new(Service::Coordinator)); + let processors = Arc::new(MessageQueue::from_env(Service::Coordinator)); let serai = || async { loop { diff --git a/deploy/processor/scripts/entry-dev.sh b/deploy/processor/scripts/entry-dev.sh index 87c2756a..a48af0dd 100755 --- a/deploy/processor/scripts/entry-dev.sh +++ b/deploy/processor/scripts/entry-dev.sh @@ -5,7 +5,9 @@ export MESSAGE_QUEUE_RPC="http://127.0.0.1:2287" export DB_PATH="./bitcoin-db" export ENTROPY="0001020304050607080910111213141516171819202122232425262728293031" -export NETWORK_RPC="http://serai:seraidex@127.0.0.1:18443" export NETWORK="bitcoin" +export NETWORK_RPC_LOGIN="serai:seraidex" +export NETWORK_RPC_HOSTNAME="127.0.0.1" +export NETWORK_RPC_PORT="18443" serai-processor diff --git a/message-queue/src/client.rs b/message-queue/src/client.rs index ea20d92d..fb1efbb2 100644 --- a/message-queue/src/client.rs +++ b/message-queue/src/client.rs @@ -26,8 +26,17 @@ pub struct MessageQueue { } impl MessageQueue { - pub fn new(service: Service) -> MessageQueue { - let url = env::var("MESSAGE_QUEUE_RPC").expect("message-queue RPC wasn't specified"); + pub fn from_env(service: Service) -> MessageQueue { + // Allow MESSAGE_QUEUE_RPC to either be a full URL or just a hostname + // While we could stitch together multiple env variables, our control over this service makes + // this fine + let mut url = env::var("MESSAGE_QUEUE_RPC").expect("message-queue RPC wasn't specified"); + if !url.contains(':') { + url += ":2287"; + } + if !url.starts_with("http://") { + url = "http://".to_string() + &url; + } let priv_key: Zeroizing<::F> = { let key_str = diff --git a/message-queue/src/main.rs b/message-queue/src/main.rs index d56cf552..8827bab0 100644 --- a/message-queue/src/main.rs +++ b/message-queue/src/main.rs @@ -110,7 +110,7 @@ fn ack_message(service: Service, id: u64, sig: SchnorrSignature) { #[tokio::main] async fn main() { if std::env::var("RUST_LOG").is_err() { - std::env::set_var("RUST_LOG", "info"); + std::env::set_var("RUST_LOG", serai_env::var("RUST_LOG").unwrap_or_else(|| "info".to_string())); } env_logger::init(); diff --git a/processor/Cargo.toml b/processor/Cargo.toml index 2bcce6ac..077d25c9 100644 --- a/processor/Cargo.toml +++ b/processor/Cargo.toml @@ -52,6 +52,7 @@ monero-serai = { path = "../coins/monero", features = ["multisig"], optional = t # Application log = "0.4" +env_logger = "0.10" tokio = { version = "1", features = ["full"] } rocksdb = "0.21" diff --git a/processor/src/main.rs b/processor/src/main.rs index c36be56c..e7c618c2 100644 --- a/processor/src/main.rs +++ b/processor/src/main.rs @@ -717,6 +717,11 @@ async fn run(mut raw_db: D, coin: C, mut coordi #[tokio::main] async fn main() { + if std::env::var("RUST_LOG").is_err() { + std::env::set_var("RUST_LOG", serai_env::var("RUST_LOG").unwrap_or_else(|| "info".to_string())); + } + env_logger::init(); + let db = Arc::new( rocksdb::TransactionDB::::open_default( env::var("DB_PATH").expect("path to DB wasn't specified"), @@ -725,14 +730,19 @@ async fn main() { ); // Network configuration - let url = env::var("NETWORK_RPC").expect("network RPC wasn't specified"); + let url = { + let login = env::var("NETWORK_RPC_LOGIN").expect("network RPC login wasn't specified"); + let hostname = env::var("NETWORK_RPC_HOSTNAME").expect("network RPC hostname wasn't specified"); + let port = env::var("NETWORK_RPC_PORT").expect("network port domain wasn't specified"); + "http://".to_string() + &login + "@" + &hostname + ":" + &port + }; let network_id = match env::var("NETWORK").expect("network wasn't specified").as_str() { "bitcoin" => NetworkId::Bitcoin, "monero" => NetworkId::Monero, _ => panic!("unrecognized network"), }; - let coordinator = MessageQueue::new(Service::Processor(network_id)); + let coordinator = MessageQueue::from_env(Service::Processor(network_id)); match network_id { #[cfg(feature = "bitcoin")]