prepare for release!
This commit was merged in pull request #8.
This commit is contained in:
@@ -73,6 +73,9 @@ pub struct ServeArgs {
|
||||
#[arg(long)]
|
||||
pub pid_file: Option<PathBuf>,
|
||||
|
||||
#[arg(long)]
|
||||
pub ui_dist_dir: Option<PathBuf>,
|
||||
|
||||
#[arg(long, visible_alias="config", default_value = DEFAULT_CONFIG_FILE)]
|
||||
pub config_file: PathBuf,
|
||||
|
||||
@@ -103,6 +106,9 @@ pub struct InitConfigArgs {
|
||||
#[arg(long)]
|
||||
pub pid_file: Option<PathBuf>,
|
||||
|
||||
#[arg(long)]
|
||||
pub ui_dist_dir: Option<PathBuf>,
|
||||
|
||||
#[arg(long)]
|
||||
pub command_timeout_ms: Option<u64>,
|
||||
|
||||
|
||||
@@ -49,6 +49,11 @@ pub fn write_init_config(args: &InitConfigArgs) -> Result<Option<PathBuf>> {
|
||||
.unwrap_or_else(|| PathBuf::from("wakey-control-plane.pid"));
|
||||
let pid_file = resolve_path(&data_dir, pid_file_raw);
|
||||
|
||||
let ui_dist_dir = args
|
||||
.ui_dist_dir
|
||||
.clone()
|
||||
.unwrap_or_else(|| PathBuf::from("ui/dist"));
|
||||
|
||||
let body = WritableConfig {
|
||||
data_dir,
|
||||
bind: bind.to_string(),
|
||||
@@ -57,6 +62,7 @@ pub fn write_init_config(args: &InitConfigArgs) -> Result<Option<PathBuf>> {
|
||||
command_timeout_ms: args.command_timeout_ms.unwrap_or(30_000).max(1),
|
||||
enroll_token_ttl_seconds: args.enroll_token_ttl_seconds.unwrap_or(86_400).max(1),
|
||||
pid_file,
|
||||
ui_dist_dir,
|
||||
bootstrap_enroll_tokens: args.bootstrap_enroll_tokens.clone(),
|
||||
telemetry: WritableTelemetry {
|
||||
otlp_endpoint: args.telemetry_otlp_endpoint.clone(),
|
||||
@@ -98,6 +104,7 @@ pub fn bootstrap_config_if_missing(args: &ServeArgs) -> Result<bool> {
|
||||
public_url: args.public_url.clone(),
|
||||
state_file: args.state_file.clone(),
|
||||
pid_file: args.pid_file.clone(),
|
||||
ui_dist_dir: args.ui_dist_dir.clone(),
|
||||
command_timeout_ms: args.command_timeout_ms,
|
||||
enroll_token_ttl_seconds: args.enroll_token_ttl_seconds,
|
||||
bootstrap_enroll_tokens: args.bootstrap_enroll_tokens.clone(),
|
||||
|
||||
@@ -73,6 +73,12 @@ impl DaemonConfig {
|
||||
.unwrap_or_else(|| PathBuf::from("wakey-control-plane.pid"));
|
||||
let pid_file = resolve_path(&data_dir, pid_file_raw);
|
||||
|
||||
let ui_dist_dir = args
|
||||
.ui_dist_dir
|
||||
.clone()
|
||||
.or(file.ui_dist_dir)
|
||||
.unwrap_or_else(|| PathBuf::from("ui/dist"));
|
||||
|
||||
let bootstrap_enroll_tokens = if args.bootstrap_enroll_tokens.is_empty() {
|
||||
file.bootstrap_enroll_tokens.unwrap_or_default()
|
||||
} else {
|
||||
@@ -89,6 +95,7 @@ impl DaemonConfig {
|
||||
command_timeout,
|
||||
enroll_token_ttl,
|
||||
pid_file,
|
||||
ui_dist_dir,
|
||||
bootstrap_enroll_tokens,
|
||||
telemetry,
|
||||
})
|
||||
|
||||
@@ -13,6 +13,7 @@ pub struct DaemonConfig {
|
||||
pub command_timeout: Duration,
|
||||
pub enroll_token_ttl: Duration,
|
||||
pub pid_file: PathBuf,
|
||||
pub ui_dist_dir: PathBuf,
|
||||
pub bootstrap_enroll_tokens: Vec<String>,
|
||||
pub telemetry: TelemetryConfig,
|
||||
}
|
||||
@@ -43,6 +44,7 @@ pub(crate) struct FileConfig {
|
||||
pub(crate) command_timeout_ms: Option<u64>,
|
||||
pub(crate) enroll_token_ttl_seconds: Option<u64>,
|
||||
pub(crate) pid_file: Option<PathBuf>,
|
||||
pub(crate) ui_dist_dir: Option<PathBuf>,
|
||||
#[serde(alias = "enroll_tokens")]
|
||||
pub(crate) bootstrap_enroll_tokens: Option<Vec<String>>,
|
||||
pub(crate) telemetry: Option<FileTelemetryConfig>,
|
||||
@@ -64,6 +66,7 @@ pub(crate) struct WritableConfig {
|
||||
pub(crate) command_timeout_ms: u64,
|
||||
pub(crate) enroll_token_ttl_seconds: u64,
|
||||
pub(crate) pid_file: PathBuf,
|
||||
pub(crate) ui_dist_dir: PathBuf,
|
||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||
pub(crate) bootstrap_enroll_tokens: Vec<String>,
|
||||
pub(crate) telemetry: WritableTelemetry,
|
||||
|
||||
@@ -57,14 +57,14 @@ pub enum AgentReply {
|
||||
Error(ErrorPayload),
|
||||
}
|
||||
|
||||
fn public_api_routes() -> Router<AppState> {
|
||||
fn public_api_routes(ui_dist_dir: std::path::PathBuf) -> Router<AppState> {
|
||||
let index_file = ui_dist_dir.join("index.html");
|
||||
|
||||
Router::new()
|
||||
.route("/ui", get(|| async { Redirect::temporary("/ui/") }))
|
||||
.nest_service(
|
||||
"/ui/",
|
||||
get_service(
|
||||
ServeDir::new("ui/dist").not_found_service(ServeFile::new("ui/dist/index.html")),
|
||||
),
|
||||
get_service(ServeDir::new(ui_dist_dir).not_found_service(ServeFile::new(index_file))),
|
||||
)
|
||||
.route("/healthz", get(api::healthz))
|
||||
.route("/api/v1/agents/enroll", post(api::enroll))
|
||||
@@ -131,11 +131,11 @@ pub async fn serve(daemon: config::DaemonConfig) -> Result<()> {
|
||||
// - public_api_routes: intended internet-facing agent endpoints
|
||||
// - control_api_routes: intended admin-only endpoints behind Access
|
||||
let app = Router::new()
|
||||
.merge(public_api_routes())
|
||||
.merge(public_api_routes(daemon.ui_dist_dir.clone()))
|
||||
.merge(control_api_routes())
|
||||
.with_state(app_state.clone());
|
||||
|
||||
info!(bind = %daemon.bind, data_dir = %daemon.data_dir.display(), pid_file = %daemon.pid_file.display(), state_file = %daemon.state_file.display(), "starting control-plane server");
|
||||
info!(bind = %daemon.bind, data_dir = %daemon.data_dir.display(), pid_file = %daemon.pid_file.display(), state_file = %daemon.state_file.display(), ui_dist_dir = %daemon.ui_dist_dir.display(), "starting control-plane server");
|
||||
let listener = TcpListener::bind(daemon.bind).await?;
|
||||
let server = tokio::spawn(async move {
|
||||
axum::serve(listener, app)
|
||||
|
||||
Reference in New Issue
Block a user