diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2022-11-07 18:01:20 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2022-11-07 18:01:20 -0800 |
commit | 79869226250beff62dde2c57a8e6e16eaa893b75 (patch) | |
tree | 897b43785b4799f0a715976551f1356a5df7983c /adenosine-pds/src/bin | |
parent | 9c8aa3d684575b5b5f169b8f6aca75919283d251 (diff) | |
download | adenosine-79869226250beff62dde2c57a8e6e16eaa893b75.tar.gz adenosine-79869226250beff62dde2c57a8e6e16eaa893b75.zip |
pds: add some more config
Diffstat (limited to 'adenosine-pds/src/bin')
-rw-r--r-- | adenosine-pds/src/bin/adenosine-pds.rs | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/adenosine-pds/src/bin/adenosine-pds.rs b/adenosine-pds/src/bin/adenosine-pds.rs index f654dc1..3587896 100644 --- a/adenosine-pds/src/bin/adenosine-pds.rs +++ b/adenosine-pds/src/bin/adenosine-pds.rs @@ -54,6 +54,12 @@ enum Command { hide_env_values = true )] pds_secret_key: String, + + #[structopt(long = "--registration-domain", env = "ATP_PDS_REGISTRATION_DOMAIN")] + registration_domain: Option<String>, + + #[structopt(long = "--public-url", env = "ATP_PDS_PUBLIC_URL")] + public_url: Option<String>, }, /// Helper to import an IPLD CARv1 file in to sqlite data store @@ -98,10 +104,29 @@ fn main() -> Result<()> { Command::Serve { port, pds_secret_key, + registration_domain, + public_url, } => { - // TODO: log some config stuff? let keypair = KeyPair::from_hex(&pds_secret_key)?; - run_server(port, &opt.blockstore_db_path, &opt.atp_db_path, keypair) + // clean up config a bit + let registration_domain = match registration_domain { + None => None, + Some(v) if v.is_empty() => None, + Some(v) => Some(v), + }; + let public_url = match public_url { + None => format!("http://localhost:{}", port), + Some(v) if v.is_empty() => format!("http://localhost:{}", port), + Some(v) => v, + }; + let config = AtpServiceConfig { + listen_host_port: format!("localhost:{}", port), + public_url: public_url, + registration_domain: registration_domain, + }; + log::info!("PDS config: {:?}", config); + let srv = AtpService::new(&opt.blockstore_db_path, &opt.atp_db_path, keypair, config)?; + srv.run_server() } // TODO: handle alias Command::Import { car_path, alias } => { |