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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user