fix compilation

main
Ziyang Hu 2 years ago
parent bd4f5bef12
commit b30ebf7b77

42
Cargo.lock generated

@ -591,6 +591,27 @@ dependencies = [
"uuid",
]
[[package]]
name = "cozo-bin"
version = "0.5.0"
dependencies = [
"chrono",
"clap 4.0.32",
"cozo",
"ctrlc",
"env_logger",
"log",
"miette",
"minreq",
"prettytable",
"rand 0.8.5",
"rouille",
"rustyline",
"serde",
"serde_derive",
"serde_json",
]
[[package]]
name = "cozo-lib-wasm"
version = "0.5.0"
@ -664,27 +685,6 @@ dependencies = [
"zstd-sys",
]
[[package]]
name = "cozoserver"
version = "0.5.0"
dependencies = [
"chrono",
"clap 4.0.32",
"cozo",
"ctrlc",
"env_logger",
"log",
"miette",
"minreq",
"prettytable",
"rand 0.8.5",
"rouille",
"rustyline",
"serde",
"serde_derive",
"serde_json",
]
[[package]]
name = "cpufeatures"
version = "0.2.5"

@ -2,7 +2,7 @@
members = [
"cozo-core",
"cozorocks",
"cozoserver",
"cozo-bin",
"cozo-lib-c",
"cozo-lib-java",
"cozo-lib-wasm",

@ -1,5 +1,5 @@
[package]
name = "cozoserver"
name = "cozo-bin"
version = "0.5.0"
edition = "2021"
license = "MPL-2.0"

@ -1,8 +1,8 @@
# CozoServer独立服务
# Cozo(独立程序
[![server](https://img.shields.io/github/v/release/cozodb/cozo)](https://github.com/cozodb/cozo/releases)
本文叙述的是如何安装设置服务程序本身。有关如何使用 CozoDBCozoScript的信息见 [文档](https://docs.cozodb.org/zh_CN/latest/index.html) 。
本文叙述的是如何安装设置 Cozo 的独立程序本身。有关如何使用 CozoDBCozoScript的信息见 [文档](https://docs.cozodb.org/zh_CN/latest/index.html) 。
## 下载

@ -1,8 +1,8 @@
# CozoServer
# Cozo (standalone executable)
[![server](https://img.shields.io/github/v/release/cozodb/cozo)](https://github.com/cozodb/cozo/releases)
This document describes how to set up cozoserver.
This document describes how to set up cozo (standalone executable).
To learn how to use CozoDB (CozoScript), read the [docs](https://docs.cozodb.org/en/latest/index.html).
## Download

@ -13,7 +13,7 @@ use std::net::Ipv6Addr;
use std::process::exit;
use std::str::FromStr;
use clap::Parser;
use clap::{Args, Parser, Subcommand};
use env_logger::Env;
use log::{error, info};
use rand::Rng;
@ -26,9 +26,25 @@ use crate::repl::repl_main;
mod repl;
#[derive(Parser, Debug)]
#[clap(version, about, long_about = None)]
struct Args {
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true)]
struct AppArgs {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
///
Server(Server),
Client(Client),
Repl(Repl),
Restore(Restore),
}
#[derive(Args, Debug)]
struct Repl {
/// Database engine, can be `mem`, `sqlite`, `rocksdb` and others.
#[clap(short, long, default_value_t = String::from("mem"))]
engine: String,
@ -37,18 +53,50 @@ struct Args {
#[clap(short, long, default_value_t = String::from("cozo.db"))]
path: String,
/// Restore from the specified backup before starting the server
#[clap(long)]
restore: Option<String>,
/// Extra config in JSON format
#[clap(short, long, default_value_t = String::from("{}"))]
config: String,
}
#[derive(Args, Debug)]
struct Client {
#[clap(default_value_t = String::from("http://127.0.0.1:9070"))]
address: String,
#[clap(short, long, default_value_t = String::from(""))]
auth: String,
}
/// When on, start REPL instead of starting a webserver
#[derive(Args, Debug)]
struct Restore {
/// Path of the backup file to restore from, must be a SQLite-backed backup file.
from: String,
/// Path of the database to restore into
to: String,
/// Database engine for the database to restore into, can be `mem`, `sqlite`, `rocksdb` and others.
#[clap(short, long)]
repl: bool,
engine: String,
}
#[derive(Args, Debug)]
struct Server {
/// Database engine, can be `mem`, `sqlite`, `rocksdb` and others.
#[clap(short, long, default_value_t = String::from("mem"))]
engine: String,
/// Path to the directory to store the database
#[clap(short, long, default_value_t = String::from("cozo.db"))]
path: String,
// Restore from the specified backup before starting the server
// #[clap(long)]
// restore: Option<String>,
/// Extra config in JSON format
#[clap(short, long, default_value_t = String::from("{}"))]
config: String,
// When on, start REPL instead of starting a webserver
// #[clap(short, long)]
// repl: bool,
/// Address to bind the service to
#[clap(short, long, default_value_t = String::from("127.0.0.1"))]
bind: String,
@ -72,7 +120,18 @@ macro_rules! check_auth {
}
fn main() {
let args = Args::parse();
let args = match AppArgs::parse().command {
Commands::Server(s) => s,
Commands::Client(_) => {
todo!()
}
Commands::Repl(_) => {
todo!()
}
Commands::Restore(_) => {
todo!()
}
};
if args.bind != "127.0.0.1" {
eprintln!("{SECURITY_WARNING}");
}
@ -84,37 +143,37 @@ fn main() {
)
.unwrap();
if let Some(restore_path) = &args.restore {
db.restore_backup(restore_path).unwrap();
}
if args.repl {
let db_copy = db.clone();
ctrlc::set_handler(move || {
let running = db_copy
.run_script("::running", Default::default())
.expect("Cannot determine running queries");
for row in running.rows {
let id = row.into_iter().next().unwrap();
eprintln!("Killing running query {id}");
db_copy
.run_script("::kill $id", BTreeMap::from([("id".to_string(), id)]))
.expect("Cannot kill process");
}
})
.expect("Error setting Ctrl-C handler");
if let Err(e) = repl_main(db) {
eprintln!("{e}");
exit(-1);
}
} else {
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
server_main(args, db)
}
// if let Some(restore_path) = &args.restore {
// db.restore_backup(restore_path).unwrap();
// }
// if args.repl {
// let db_copy = db.clone();
// ctrlc::set_handler(move || {
// let running = db_copy
// .run_script("::running", Default::default())
// .expect("Cannot determine running queries");
// for row in running.rows {
// let id = row.into_iter().next().unwrap();
// eprintln!("Killing running query {id}");
// db_copy
// .run_script("::kill $id", BTreeMap::from([("id".to_string(), id)]))
// .expect("Cannot kill process");
// }
// })
// .expect("Error setting Ctrl-C handler");
//
// if let Err(e) = repl_main(db) {
// eprintln!("{e}");
// exit(-1);
// }
// } else {
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
server_main(args, db)
// }
}
fn server_main(args: Args, db: DbInstance) {
fn server_main(args: Server, db: DbInstance) {
let conf_path = format!("{}.{}.cozo_auth", args.path, args.engine);
let auth_guard = match fs::read_to_string(&conf_path) {
Ok(s) => s.trim().to_string(),

@ -74,7 +74,6 @@ pub use crate::runtime::callback::CallbackOp;
pub use crate::runtime::db::Poison;
pub use crate::runtime::db::TransactionPayload;
#[cfg(not(target_arch = "wasm32"))]
pub(crate) mod data;
pub(crate) mod fixed_rule;
pub(crate) mod parse;

@ -42,7 +42,7 @@ impl CallbackOp {
}
}
#[cfg(not(target_arch = "wasm32"))]
#[allow(dead_code)]
pub struct CallbackDeclaration {
pub(crate) dependent: SmartString<LazyCompact>,
pub(crate) sender: Sender<(CallbackOp, NamedRows, NamedRows)>,
@ -51,7 +51,7 @@ pub struct CallbackDeclaration {
pub(crate) type CallbackCollector =
BTreeMap<SmartString<LazyCompact>, Vec<(CallbackOp, NamedRows, NamedRows)>>;
#[cfg(not(target_arch = "wasm32"))]
#[allow(dead_code)]
pub(crate) type EventCallbackRegistry = (
BTreeMap<u32, CallbackDeclaration>,
BTreeMap<SmartString<LazyCompact>, BTreeSet<u32>>,

@ -20,6 +20,7 @@ use std::thread;
#[allow(unused_imports)]
use std::time::{Duration, SystemTime, UNIX_EPOCH};
#[allow(unused_imports)]
use crossbeam::channel::{bounded, unbounded, Receiver, Sender};
use crossbeam::sync::ShardedLock;
use either::{Left, Right};
@ -45,6 +46,7 @@ use crate::query::ra::{
FilteredRA, InnerJoin, NegJoin, RelAlgebra, ReorderRA, StoredRA, StoredWithValidityRA,
TempStoreRA, UnificationRA,
};
#[allow(unused_imports)]
use crate::runtime::callback::{
CallbackCollector, CallbackDeclaration, CallbackOp, EventCallbackRegistry,
};

@ -14,8 +14,8 @@ cp target/wheels/*.whl release/
for TARGET in aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu; do
# standalone, c, java, nodejs
CARGO_PROFILE_RELEASE_LTO=fat cross build --release -p cozoserver -p cozo_c -p cozo_java -p cozo-node -F compact -F storage-rocksdb --target $TARGET
cp target/$TARGET/release/cozoserver release/cozoserver-$VERSION-$TARGET # standalone
CARGO_PROFILE_RELEASE_LTO=fat cross build --release -p cozo-bin -p cozo_c -p cozo_java -p cozo-node -F compact -F storage-rocksdb --target $TARGET
cp target/$TARGET/release/cozo-bin release/cozo-$VERSION-$TARGET # standalone
cp target/$TARGET/release/libcozo_c.a release/libcozo_c-$VERSION-$TARGET.a # c static
cp target/$TARGET/release/libcozo_c.so release/libcozo_c-$VERSION-$TARGET.so # c dynamic
cp target/$TARGET/release/libcozo_java.so release/libcozo_java-$VERSION-$TARGET.so # java
@ -24,14 +24,14 @@ for TARGET in aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu; do
done
for TARGET in x86_64-unknown-linux-gnu; do
PROTOC=$PWD/tools/protoc CARGO_PROFILE_RELEASE_LTO=fat cross build --release -p cozoserver \
PROTOC=$PWD/tools/protoc CARGO_PROFILE_RELEASE_LTO=fat cross build --release -p cozo-bin \
-F compact -F storage-rocksdb -F storage-tikv -F storage-sled --target $TARGET
cp target/$TARGET/release/cozoserver release/cozoserver_all-$VERSION-$TARGET # standalone
cp target/$TARGET/release/cozo-bin release/cozo_all-$VERSION-$TARGET # standalone
done
for TARGET in aarch64-unknown-linux-musl x86_64-unknown-linux-musl; do
CARGO_PROFILE_RELEASE_LTO=fat cross build --release -p cozoserver -p cozo_c -F compact -F storage-rocksdb --target $TARGET
cp target/$TARGET/release/cozoserver release/cozoserver-$VERSION-$TARGET # standalone
CARGO_PROFILE_RELEASE_LTO=fat cross build --release -p cozo-bin -p cozo_c -F compact -F storage-rocksdb --target $TARGET
cp target/$TARGET/release/cozo-bin release/cozo-$VERSION-$TARGET # standalone
cp target/$TARGET/release/libcozo_c.a release/libcozo_c-$VERSION-$TARGET.a # c static
done

@ -10,8 +10,8 @@ mkdir -p release
for TARGET in aarch64-apple-darwin x86_64-apple-darwin; do
# standalone, c, java, nodejs
CARGO_PROFILE_RELEASE_LTO=fat cargo build --release -p cozoserver -p cozo_c -p cozo_java -p cozo-node -F compact -F storage-rocksdb --target $TARGET
cp target/$TARGET/release/cozoserver release/cozoserver-$VERSION-$TARGET # standalone
CARGO_PROFILE_RELEASE_LTO=fat cargo build --release -p cozo-bin -p cozo_c -p cozo_java -p cozo-node -F compact -F storage-rocksdb --target $TARGET
cp target/$TARGET/release/cozo-bin release/cozo-$VERSION-$TARGET # standalone
cp target/$TARGET/release/libcozo_c.a release/libcozo_c-$VERSION-$TARGET.a # c static
cp target/$TARGET/release/libcozo_c.dylib release/libcozo_c-$VERSION-$TARGET.dylib # c dynamic
cp target/$TARGET/release/libcozo_java.dylib release/libcozo_java-$VERSION-$TARGET.dylib # java
@ -33,9 +33,9 @@ cd ..
# with TiKV
for TARGET in aarch64-apple-darwin x86_64-apple-darwin; do
CARGO_PROFILE_RELEASE_LTO=fat cargo build --release -p cozoserver \
CARGO_PROFILE_RELEASE_LTO=fat cargo build --release -p cozo-bin \
-F compact -F storage-rocksdb -F storage-tikv -F storage-sled --target $TARGET
cp target/$TARGET/release/cozoserver release/cozoserver_all-$VERSION-$TARGET # standalone
cp target/$TARGET/release/cozo-bin release/cozo_all-$VERSION-$TARGET # standalone
done
# WASM

@ -11,8 +11,8 @@ cd cozo-lib-python
maturin build -F compact -F storage-rocksdb --release --strip --target $TARGET
cd ..
cargo build --release -p cozoserver -p cozo_c -p cozo_java -p cozo-node -F compact -F storage-rocksdb --target $TARGET
cp target/$TARGET/release/cozoserver.exe release/cozoserver-$VERSION-$TARGET.exe # standalone
cargo build --release -p cozo-bin -p cozo_c -p cozo_java -p cozo-node -F compact -F storage-rocksdb --target $TARGET
cp target/$TARGET/release/cozo-bin.exe release/cozo-$VERSION-$TARGET.exe # standalone
cp target/$TARGET/release/cozo_c.lib release/libcozo_c-$VERSION-$TARGET.lib # c static
cp target/$TARGET/release/cozo_c.dll release/libcozo_c-$VERSION-$TARGET.dll # c dynamic
cp target/$TARGET/release/cozo_java.dll release/libcozo_java-$VERSION-$TARGET.dll # java
@ -21,8 +21,8 @@ cp target/$TARGET/release/cozo_node.dll release/libcozo_node-$VERSION-$TARGET.dl
cp target/wheels/*.whl release/
$TARGET = "x86_64-pc-windows-gnu"
cargo build --release -p cozoserver -p cozo_c -p cozo_java -p cozo-node -F compact -F storage-rocksdb --target $TARGET
cp target/$TARGET/release/cozoserver.exe release/cozoserver-$VERSION-$TARGET.exe # standalone
cargo build --release -p cozo-bin -p cozo_c -p cozo_java -p cozo-node -F compact -F storage-rocksdb --target $TARGET
cp target/$TARGET/release/cozo-bin.exe release/cozo-$VERSION-$TARGET.exe # standalone
cp target/$TARGET/release/libcozo_c.a release/libcozo_c-$VERSION-$TARGET.a # c static
cp target/$TARGET/release/cozo_c.dll release/libcozo_c-$VERSION-$TARGET.dll # c dynamic
cp target/$TARGET/release/cozo_java.dll release/libcozo_java-$VERSION-$TARGET.dll # java

Loading…
Cancel
Save