mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-12 08:51:11 +00:00
figcraft-server hosts many files over the same hub the app uses for sessions, persists each as a checksummed snapshot plus an append-only log (synced before replies, compacted, damaged files skipped and reported) so restarts lose nothing confirmed, and gives per-file share links with edit or view access (hashed 128-bit tokens, revocable). The app can publish a file to a server and join server-hosted files; view-only tabs refuse edits. Protocol version 2.
41 lines
1.2 KiB
Rust
41 lines
1.2 KiB
Rust
//! `figcraft-server`: see `docs/server.md`, or run it with `--help`.
|
|
|
|
use std::process::ExitCode;
|
|
|
|
use figcraft_server::cli::{self, Command};
|
|
|
|
fn main() -> ExitCode {
|
|
let args: Vec<String> = std::env::args().skip(1).collect();
|
|
let cli = match cli::parse(&args) {
|
|
Ok(c) => c,
|
|
Err(e) => {
|
|
eprintln!("figcraft-server: {e}\n(figcraft-server --help lists what it takes)");
|
|
return ExitCode::from(2);
|
|
}
|
|
};
|
|
if cli.command != Command::Serve {
|
|
return match cli::run(&cli) {
|
|
Ok(out) => {
|
|
print!("{out}");
|
|
ExitCode::SUCCESS
|
|
}
|
|
Err(e) => {
|
|
eprintln!("figcraft-server: {e}");
|
|
ExitCode::FAILURE
|
|
}
|
|
};
|
|
}
|
|
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).target(env_logger::Target::Stdout).init();
|
|
match figcraft_server::start(&cli.config) {
|
|
// Serves until the process is stopped: what was confirmed is on disk already, and clients
|
|
// reconnect once it runs again.
|
|
Ok(_running) => loop {
|
|
std::thread::park();
|
|
},
|
|
Err(e) => {
|
|
log::error!("{e}");
|
|
ExitCode::FAILURE
|
|
}
|
|
}
|
|
}
|