Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

added bind options for both service port and metrics port for spacedust, slingshot, and ufso

+45 -37
+14 -11
slingshot/src/main.rs
··· 49 49 /// an web address to send healtcheck pings to every ~51s or so 50 50 #[arg(long)] 51 51 healthcheck: Option<String>, 52 + /// slingshot server's listen address 53 + #[arg(long, default_value = "0.0.0.0:8080")] 54 + bind: std::net::SocketAddr, 55 + /// metrics server's listen address 56 + #[arg(long, default_value = "0.0.0.0:8765")] 57 + bind_metrics: std::net::SocketAddr, 52 58 } 53 59 54 60 #[tokio::main] ··· 62 68 63 69 let args = Args::parse(); 64 70 65 - if let Err(e) = install_metrics_server() { 71 + if let Err(e) = install_metrics_server(args.bind_metrics) { 66 72 log::error!("failed to install metrics server: {e:?}"); 67 73 } else { 68 - log::info!("metrics listening at http://0.0.0.0:8765"); 74 + log::info!("metrics listening at http://{}", args.bind_metrics); 69 75 } 70 76 71 77 std::fs::create_dir_all(&args.cache_dir).map_err(|e| { ··· 104 110 105 111 let server_shutdown = shutdown.clone(); 106 112 let server_cache_handle = cache.clone(); 113 + let bind = args.bind; 107 114 tasks.spawn(async move { 108 115 serve( 109 116 server_cache_handle, ··· 113 120 args.acme_contact, 114 121 args.certs, 115 122 server_shutdown, 123 + bind, 116 124 ) 117 125 .await?; 118 126 Ok(()) ··· 172 180 Ok(()) 173 181 } 174 182 175 - fn install_metrics_server() -> Result<(), metrics_exporter_prometheus::BuildError> { 183 + fn install_metrics_server(bind_metrics: std::net::SocketAddr) -> Result<(), metrics_exporter_prometheus::BuildError> { 176 184 log::info!("installing metrics server..."); 177 - let host = [0, 0, 0, 0]; 178 - let port = 8765; 179 185 PrometheusBuilder::new() 180 186 .set_quantiles(&[0.5, 0.9, 0.99, 1.0])? 181 187 .set_bucket_duration(std::time::Duration::from_secs(300))? 182 188 .set_bucket_count(std::num::NonZero::new(12).unwrap()) // count * duration = 60 mins. stuff doesn't happen that fast here. 183 189 .set_enable_unit_suffix(false) // this seemed buggy for constellation (sometimes wouldn't engage) 184 - .with_http_listener((host, port)) 190 + .with_http_listener(bind_metrics) 185 191 .install()?; 186 192 log::info!( 187 - "metrics server installed! listening on http://{}.{}.{}.{}:{port}", 188 - host[0], 189 - host[1], 190 - host[2], 191 - host[3] 193 + "metrics server installed! listening on http://{}", 194 + bind_metrics 192 195 ); 193 196 Ok(()) 194 197 }
+2 -1
slingshot/src/server.rs
··· 695 695 acme_contact: Option<String>, 696 696 certs: Option<PathBuf>, 697 697 shutdown: CancellationToken, 698 + bind: std::net::SocketAddr, 698 699 ) -> Result<(), ServerError> { 699 700 let repo = Arc::new(repo); 700 701 let api_service = OpenApiService::new( ··· 752 753 ) 753 754 .await 754 755 } else { 755 - run(TcpListener::bind("127.0.0.1:3000"), app, shutdown).await 756 + run(TcpListener::bind(bind.to_string()), app, shutdown).await 756 757 } 757 758 } 758 759
+13 -11
spacedust/src/main.rs
··· 23 23 /// reduces CPU at the expense of more ingress bandwidth 24 24 #[arg(long, action)] 25 25 jetstream_no_zstd: bool, 26 + /// spacedust server's listen address 27 + #[arg(long, default_value = "0.0.0.0:9998")] 28 + bind: std::net::SocketAddr, 29 + /// metrics server's listen address 30 + #[arg(long, default_value = "0.0.0.0:8765")] 31 + bind_metrics: std::net::SocketAddr, 26 32 } 27 33 28 34 #[tokio::main] ··· 60 66 61 67 let args = Args::parse(); 62 68 63 - if let Err(e) = install_metrics_server() { 69 + if let Err(e) = install_metrics_server(args.bind_metrics) { 64 70 log::error!("failed to install metrics server: {e:?}"); 65 71 }; 66 72 67 73 let mut tasks: tokio::task::JoinSet<Result<(), MainTaskError>> = tokio::task::JoinSet::new(); 68 74 69 75 let server_shutdown = shutdown.clone(); 76 + let bind = args.bind; 70 77 tasks.spawn(async move { 71 - server::serve(b, d, server_shutdown).await?; 78 + server::serve(b, d, server_shutdown, bind).await?; 72 79 Ok(()) 73 80 }); 74 81 ··· 122 129 Ok(()) 123 130 } 124 131 125 - fn install_metrics_server() -> Result<(), metrics_exporter_prometheus::BuildError> { 132 + fn install_metrics_server(bind_metrics: std::net::SocketAddr) -> Result<(), metrics_exporter_prometheus::BuildError> { 126 133 log::info!("installing metrics server..."); 127 - let host = [0, 0, 0, 0]; 128 - let port = 8765; 129 134 PrometheusBuilder::new() 130 135 .set_quantiles(&[0.5, 0.9, 0.99, 1.0])? 131 136 .set_bucket_duration(std::time::Duration::from_secs(300))? 132 137 .set_bucket_count(std::num::NonZero::new(12).unwrap()) // count * duration = 60 mins. stuff doesn't happen that fast here. 133 138 .set_enable_unit_suffix(false) // this seemed buggy for constellation (sometimes wouldn't engage) 134 - .with_http_listener((host, port)) 139 + .with_http_listener(bind_metrics) 135 140 .install()?; 136 141 log::info!( 137 - "metrics server installed! listening on http://{}.{}.{}.{}:{port}", 138 - host[0], 139 - host[1], 140 - host[2], 141 - host[3] 142 + "metrics server installed! listening on http://{}", 143 + bind_metrics 142 144 ); 143 145 Ok(()) 144 146 }
+2 -1
spacedust/src/server.rs
··· 29 29 b: broadcast::Sender<Arc<ClientMessage>>, 30 30 d: broadcast::Sender<Arc<ClientMessage>>, 31 31 shutdown: CancellationToken, 32 + bind: std::net::SocketAddr, 32 33 ) -> Result<(), ServerError> { 33 34 let config_logging = ConfigLogging::StderrTerminal { 34 35 level: ConfigLoggingLevel::Info, ··· 72 73 73 74 let server = ServerBuilder::new(api, ctx, log) 74 75 .config(ConfigDropshot { 75 - bind_address: "0.0.0.0:9998".parse().unwrap(), 76 + bind_address: bind, 76 77 ..Default::default() 77 78 }) 78 79 .start()?;
+12 -11
ufos/src/main.rs
··· 55 55 /// DEBUG: interpret jetstream as a file fixture 56 56 #[arg(long, action)] 57 57 jetstream_fixture: bool, 58 + /// ufos server's listen address 59 + #[arg(long, default_value = "0.0.0.0:9990")] 60 + bind: std::net::SocketAddr, 61 + /// metrics server's listen address 62 + #[arg(long, default_value = "0.0.0.0:8765")] 63 + bind_metrics: std::net::SocketAddr, 58 64 } 59 65 60 66 #[tokio::main] ··· 84 90 let mut consumer_tasks: JoinSet<anyhow::Result<()>> = JoinSet::new(); 85 91 86 92 println!("starting server with storage..."); 87 - let serving = server::serve(read_store.clone()); 93 + let serving = server::serve(read_store.clone(), args.bind); 88 94 whatever_tasks.spawn(async move { 89 95 serving.await.map_err(|e| { 90 96 log::warn!("server ended: {e}"); ··· 137 143 Ok(()) 138 144 }); 139 145 140 - install_metrics_server()?; 146 + install_metrics_server(args.bind_metrics)?; 141 147 142 148 for (i, t) in consumer_tasks.join_all().await.iter().enumerate() { 143 149 log::warn!("task {i} done: {t:?}"); ··· 151 157 Ok(()) 152 158 } 153 159 154 - fn install_metrics_server() -> anyhow::Result<()> { 160 + fn install_metrics_server(bind_metrics: std::net::SocketAddr) -> anyhow::Result<()> { 155 161 log::info!("installing metrics server..."); 156 - let host = [0, 0, 0, 0]; 157 - let port = 8765; 158 162 PrometheusBuilder::new() 159 163 .set_quantiles(&[0.5, 0.9, 0.99, 1.0])? 160 164 .set_bucket_duration(Duration::from_secs(60))? 161 165 .set_bucket_count(std::num::NonZero::new(10).unwrap()) // count * duration = 10 mins. stuff doesn't happen that fast here. 162 166 .set_enable_unit_suffix(false) // this seemed buggy for constellation (sometimes wouldn't engage) 163 - .with_http_listener((host, port)) 167 + .with_http_listener(bind_metrics) 164 168 .install()?; 165 169 log::info!( 166 - "metrics server installed! listening on http://{}.{}.{}.{}:{port}", 167 - host[0], 168 - host[1], 169 - host[2], 170 - host[3] 170 + "metrics server installed! listening on http://{}", 171 + bind_metrics 171 172 ); 172 173 Ok(()) 173 174 }
+2 -2
ufos/src/server/mod.rs
··· 716 716 .await 717 717 } 718 718 719 - pub async fn serve(storage: impl StoreReader + 'static) -> Result<(), String> { 719 + pub async fn serve(storage: impl StoreReader + 'static, bind: std::net::SocketAddr) -> Result<(), String> { 720 720 describe_metrics(); 721 721 let log = ConfigLogging::StderrTerminal { 722 722 level: ConfigLoggingLevel::Warn, ··· 758 758 759 759 ServerBuilder::new(api, context, log) 760 760 .config(ConfigDropshot { 761 - bind_address: "0.0.0.0:9999".parse().unwrap(), 761 + bind_address: bind, 762 762 ..Default::default() 763 763 }) 764 764 .start()