Public release release-f6c01dca61ee
Source commit: f6c01dca61eefca1a7431c48878a04dbb7a3f710 Public tree identity: sha256:3df7a93eb61c8c5c7841ac9ad6eedec89b167fd77fdd32e9fc31b57c10207387
This commit is contained in:
commit
a2664f4345
210 changed files with 78559 additions and 0 deletions
62
crates/clusterflux-coordinator/src/main.rs
Normal file
62
crates/clusterflux-coordinator/src/main.rs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
use std::io::Write;
|
||||
|
||||
use clusterflux_coordinator::{service::bind_listener, CoordinatorService};
|
||||
use clusterflux_core::{ProjectId, TenantId, UserId};
|
||||
use serde_json::json;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut listen = "127.0.0.1:0".to_owned();
|
||||
let mut allow_local_trusted = std::env::var("CLUSTERFLUX_ALLOW_LOCAL_TRUSTED_LOOPBACK")
|
||||
.ok()
|
||||
.as_deref()
|
||||
== Some("1");
|
||||
let mut args = std::env::args().skip(1);
|
||||
while let Some(arg) = args.next() {
|
||||
if arg == "--listen" {
|
||||
listen = args.next().ok_or("--listen requires an address")?;
|
||||
} else if arg == "--allow-local-trusted-loopback" {
|
||||
allow_local_trusted = true;
|
||||
}
|
||||
}
|
||||
|
||||
let (listener, addr) = bind_listener(&listen)?;
|
||||
let database_url = std::env::var("DATABASE_URL").ok();
|
||||
let mut service = CoordinatorService::new_with_database_url(1, database_url.as_deref())?;
|
||||
let self_hosted_session_secret = std::env::var("CLUSTERFLUX_SELF_HOSTED_SESSION_SECRET")
|
||||
.ok()
|
||||
.filter(|secret| !secret.trim().is_empty());
|
||||
if let Some(session_secret) = self_hosted_session_secret.as_deref() {
|
||||
service.issue_cli_session(
|
||||
TenantId::new(
|
||||
std::env::var("CLUSTERFLUX_SELF_HOSTED_TENANT")
|
||||
.unwrap_or_else(|_| "tenant".to_owned()),
|
||||
),
|
||||
ProjectId::new(
|
||||
std::env::var("CLUSTERFLUX_SELF_HOSTED_PROJECT")
|
||||
.unwrap_or_else(|_| "project".to_owned()),
|
||||
),
|
||||
UserId::new(
|
||||
std::env::var("CLUSTERFLUX_SELF_HOSTED_USER").unwrap_or_else(|_| "user".to_owned()),
|
||||
),
|
||||
session_secret,
|
||||
None,
|
||||
)?;
|
||||
}
|
||||
println!(
|
||||
"{}",
|
||||
json!({
|
||||
"listen": addr.to_string(),
|
||||
"client_authority": if allow_local_trusted { "local_trusted_loopback" } else { "strict" },
|
||||
"self_hosted_session_bootstrapped": self_hosted_session_secret.is_some(),
|
||||
"durable_store": service.durable_store_kind(),
|
||||
})
|
||||
);
|
||||
std::io::stdout().flush()?;
|
||||
|
||||
if allow_local_trusted {
|
||||
service.serve_tcp_local_trusted(listener)?;
|
||||
} else {
|
||||
service.serve_tcp(listener)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue