Support creating a standalone sync server

This commit is contained in:
Damien Elmes 2023-07-02 14:33:38 +10:00
parent 0f77de896d
commit 8c712cd118
4 changed files with 38 additions and 0 deletions

7
Cargo.lock generated
View File

@ -164,6 +164,13 @@ dependencies = [
"zstd",
]
[[package]]
name = "anki-sync-server"
version = "0.0.0"
dependencies = [
"anki",
]
[[package]]
name = "anki_i18n"
version = "0.0.0"

View File

@ -14,6 +14,7 @@ members = [
"rslib/proto",
"rslib/io",
"rslib/process",
"rslib/sync",
"pylib/rsbridge",
"build/configure",
"build/ninja_gen",

16
rslib/sync/Cargo.toml Normal file
View File

@ -0,0 +1,16 @@
[package]
name = "anki-sync-server"
version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true
publish = false
rust-version.workspace = true
description = "Standalone sync server"
[[bin]]
path = "main.rs"
name = "anki-sync-server"
[dependencies]
anki.workspace = true

14
rslib/sync/main.rs Normal file
View File

@ -0,0 +1,14 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use std::env;
use anki::log::set_global_logger;
use anki::sync::http_server::SimpleServer;
fn main() {
if env::var("RUST_LOG").is_err() {
env::set_var("RUST_LOG", "anki=info")
}
set_global_logger(None).unwrap();
println!("{}", SimpleServer::run());
}