diff --git a/scripts/deploy_sandbox_server.sh b/scripts/deploy_sandbox_server.sh index f1a6ece..2f52c15 100755 --- a/scripts/deploy_sandbox_server.sh +++ b/scripts/deploy_sandbox_server.sh @@ -1,3 +1,3 @@ #!/bin/sh -. ./scripts/env.sh && cargo run --no-default-features --features "server" -- ${1:-0.0.0.0:4000} --cert certs/certificate.crt --key certs/private.key +. ./scripts/env.sh && cargo run --no-default-features --features "server" -- ${1:-0.0.0.0:4000} diff --git a/scripts/env.sh b/scripts/env.sh index 9bb1966..79e6026 100755 --- a/scripts/env.sh +++ b/scripts/env.sh @@ -1,5 +1,8 @@ #!/bin/sh +export CONFIG_CERT_FILE="./certs/certificate.crt" +export CONFIG_KEY_FILE="./certs/private.key" + export DB_HOST="database" [ -z "$CI_DEPLOY" ] && export DB_HOST="localhost" diff --git a/src/libtrader/server/initializer.rs b/src/libtrader/server/initializer.rs index bc86619..f16798d 100644 --- a/src/libtrader/server/initializer.rs +++ b/src/libtrader/server/initializer.rs @@ -1,6 +1,6 @@ use std::io; use std::net::ToSocketAddrs; -use std::path::PathBuf; +use std::path::Path; use std::sync::Arc; use argh::FromArgs; @@ -21,14 +21,6 @@ struct Options { /// bind addr #[argh(positional)] addr: String, - - /// cert file - #[argh(option, short = 'c')] - cert: PathBuf, - - /// key file - #[argh(option, short = 'k')] - key: PathBuf, } tokio::task_local! { @@ -159,7 +151,8 @@ pub async fn libtrader_init_server() -> std::io::Result<()> { .next() .ok_or_else(|| std::io::Error::from(std::io::ErrorKind::AddrNotAvailable))?; - let config = gen_tls_server_config(&options.cert, &options.key)?; + let config = gen_tls_server_config(&Path::new(&std::env::var("CONFIG_CERT_FILE").unwrap()), + &Path::new(&std::env::var("CONFIG_KEY_FILE").unwrap()))?; let acceptor = TlsAcceptor::from(config); let listener = TcpListener::bind(&addr).await?; diff --git a/todo/v1.libtrader.md b/todo/v1.libtrader.md index 7d25f92..1305c84 100644 --- a/todo/v1.libtrader.md +++ b/todo/v1.libtrader.md @@ -1,6 +1,5 @@ ## To do -- use env.sh or arguments - server move network code to somewhere plausable. - create correct modules - data implmentation stuff @@ -19,7 +18,7 @@ ## In progress -- configure drone ci +- use env.sh or arguments ## Done @@ -141,3 +140,4 @@ * [x] Saving/Loading stock values * [x] Saving/Loading profiles/portfolios * [x] Saving/Loading company values +- configure drone ci