Add CLI arguments for multi-instance support

Added --db-path and --control-socket arguments to app binary to enable
running multiple instances simultaneously.

Updated marathonctl to use clap with --socket argument for targeting
different instances.

Enables multi-client testing with isolated databases and control sockets.

Refs #131, #132

Signed-off-by: Sienna Meridian Satterwhite <sienna@r3t.io>
This commit is contained in:
2025-12-24 11:58:30 +00:00
parent da886452bd
commit a0c13be6d6
5 changed files with 376 additions and 3 deletions

View File

@@ -3,6 +3,7 @@
//! This demonstrates real-time CRDT synchronization with Apple Pencil input.
use bevy::prelude::*;
use clap::Parser;
use libmarathon::{
engine::{
EngineBridge,
@@ -16,6 +17,19 @@ use bevy::app::ScheduleRunnerPlugin;
#[cfg(feature = "headless")]
use std::time::Duration;
/// Marathon - CRDT-based collaborative editing engine
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
/// Path to the database file
#[arg(long, default_value = "marathon.db")]
db_path: String,
/// Path to the control socket (Unix domain socket)
#[arg(long, default_value = "/tmp/marathon-control.sock")]
control_socket: String,
}
mod camera;
mod control;
mod cube;
@@ -40,6 +54,9 @@ use session::*;
use session_ui::*;
fn main() {
// Parse command-line arguments
let args = Args::parse();
// Note: eprintln doesn't work on iOS, but tracing-oslog will once initialized
eprintln!(">>> RUST ENTRY: main() started");
@@ -81,9 +98,8 @@ fn main() {
// Application configuration
const APP_NAME: &str = "Aspen";
// Get platform-appropriate database path
eprintln!(">>> Getting database path");
let db_path = libmarathon::platform::get_database_path(APP_NAME);
// Use database path from CLI args
let db_path = std::path::PathBuf::from(&args.db_path);
let db_path_str = db_path.to_str().unwrap().to_string();
info!("Database path: {}", db_path_str);
eprintln!(">>> Database path: {}", db_path_str);
@@ -185,6 +201,9 @@ fn main() {
app.add_plugins(EngineBridgePlugin);
app.add_plugins(CubePlugin);
app.add_systems(Startup, initialize_offline_resources);
// Insert control socket path as resource
app.insert_resource(control::ControlSocketPath(args.control_socket.clone()));
app.add_systems(Startup, control::start_control_socket_system);
// Rendering-only plugins