memoryd: serve, three sockets and one lock over the files and the index

Implemented-By: OpenCode session (model recorded in docs/implementer-log.md)
This commit is contained in:
2026-09-25 16:41:44 -07:00
committed by kyle
parent 49af057c81
commit 0c8d136c6b
6 changed files with 740 additions and 7 deletions
+25 -7
View File
@@ -3,22 +3,40 @@
use std::ffi::OsString;
use std::path::PathBuf;
use std::process::ExitCode;
use std::sync::Arc;
use memoryd::config::Config;
use memoryd::serve;
const USAGE: &str = "usage: memoryd serve --config <path>";
const START_FAILED: &str = "see docs/runbook.md#memoryd-start-failed";
fn main() -> ExitCode {
let args: Vec<OsString> = std::env::args_os().skip(1).collect();
let Some(config) = parse(&args) else {
let Some(path) = parse(&args) else {
eprintln!("{USAGE}");
return ExitCode::from(2);
};
match memoryd::config::Config::load(&config) {
Ok(_) => {
eprintln!("memoryd: not implemented");
ExitCode::from(2)
}
let config = match Config::load(&path) {
Ok(config) => config,
Err(e) => {
eprintln!("memoryd: {e}\nsee docs/runbook.md#memoryd-start-failed");
eprintln!("memoryd: {e}\n{START_FAILED}");
return ExitCode::from(1);
}
};
let log: serve::Log = Arc::new(|line: &str| eprintln!("{line}"));
let running = match serve::start(config, log) {
Ok(running) => running,
Err(e) => {
eprintln!("memoryd: {e}\n{START_FAILED}");
return ExitCode::from(1);
}
};
eprintln!("memoryd: serving");
match running.run() {
Ok(()) => ExitCode::SUCCESS,
Err(e) => {
eprintln!("memoryd: stopped serving: {e}\n{START_FAILED}");
ExitCode::from(1)
}
}