2022-05-10 10:53:30 +00:00
|
|
|
//! This binary is the web-platform server for [SurrealDB](https://surrealdb.com) the
|
|
|
|
//! ultimate cloud database for tomorrow's applications. SurrealDB is a scalable,
|
|
|
|
//! distributed, collaborative, document-graph database for the realtime web.
|
|
|
|
//!
|
|
|
|
//! This binary can be used to start a database server instance using an embedded
|
|
|
|
//! in-memory datastore, or an embedded datastore persisted to disk. In addition, it
|
|
|
|
//! can be used in distributed mode by connecting to a distributed [TiKV](https://tikv.org)
|
|
|
|
//! key-value store.
|
|
|
|
|
2023-02-03 11:46:39 +00:00
|
|
|
#![deny(clippy::mem_forget)]
|
2022-03-23 15:12:29 +00:00
|
|
|
#![forbid(unsafe_code)]
|
|
|
|
|
2020-06-29 15:36:01 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate log;
|
|
|
|
|
2023-07-03 20:23:18 +00:00
|
|
|
#[cfg(any(
|
|
|
|
feature = "storage-mem",
|
|
|
|
feature = "storage-tikv",
|
|
|
|
feature = "storage-rocksdb",
|
|
|
|
feature = "storage-speedb",
|
|
|
|
feature = "storage-fdb",
|
|
|
|
))]
|
2022-01-13 17:36:41 +00:00
|
|
|
#[macro_use]
|
|
|
|
mod mac;
|
|
|
|
|
2020-06-29 15:36:01 +00:00
|
|
|
mod cli;
|
2022-01-13 17:36:41 +00:00
|
|
|
mod cnf;
|
2023-07-03 20:23:18 +00:00
|
|
|
#[cfg(any(
|
|
|
|
feature = "storage-mem",
|
|
|
|
feature = "storage-tikv",
|
|
|
|
feature = "storage-rocksdb",
|
|
|
|
feature = "storage-speedb",
|
|
|
|
feature = "storage-fdb",
|
|
|
|
))]
|
2022-07-04 00:01:24 +00:00
|
|
|
mod dbs;
|
2022-10-27 08:58:08 +00:00
|
|
|
mod env;
|
2020-06-29 15:36:01 +00:00
|
|
|
mod err;
|
2023-07-03 20:23:18 +00:00
|
|
|
#[cfg(any(
|
|
|
|
feature = "storage-mem",
|
|
|
|
feature = "storage-tikv",
|
|
|
|
feature = "storage-rocksdb",
|
|
|
|
feature = "storage-speedb",
|
|
|
|
feature = "storage-fdb",
|
|
|
|
))]
|
2022-07-04 00:01:24 +00:00
|
|
|
mod iam;
|
2023-07-03 20:23:18 +00:00
|
|
|
#[cfg(any(
|
|
|
|
feature = "storage-mem",
|
|
|
|
feature = "storage-tikv",
|
|
|
|
feature = "storage-rocksdb",
|
|
|
|
feature = "storage-speedb",
|
|
|
|
feature = "storage-fdb",
|
|
|
|
))]
|
2022-02-09 15:55:04 +00:00
|
|
|
mod net;
|
2023-03-29 18:16:18 +00:00
|
|
|
mod o11y;
|
2023-07-03 20:23:18 +00:00
|
|
|
#[cfg(any(
|
|
|
|
feature = "storage-mem",
|
|
|
|
feature = "storage-tikv",
|
|
|
|
feature = "storage-rocksdb",
|
|
|
|
feature = "storage-speedb",
|
|
|
|
feature = "storage-fdb",
|
|
|
|
))]
|
2022-07-04 01:03:26 +00:00
|
|
|
mod rpc;
|
2020-06-29 15:36:01 +00:00
|
|
|
|
2023-05-22 19:19:35 +00:00
|
|
|
use std::future::Future;
|
2022-12-31 08:03:19 +00:00
|
|
|
use std::process::ExitCode;
|
|
|
|
|
|
|
|
fn main() -> ExitCode {
|
2023-05-22 19:19:35 +00:00
|
|
|
// Initiate the command line
|
|
|
|
with_enough_stack(cli::init())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Rust's default thread stack size of 2MiB doesn't allow sufficient recursion depth.
|
|
|
|
fn with_enough_stack<T>(fut: impl Future<Output = T> + Send) -> T {
|
|
|
|
let stack_size = 8 * 1024 * 1024;
|
|
|
|
|
|
|
|
// Stack frames are generally larger in debug mode.
|
|
|
|
#[cfg(debug_assertions)]
|
|
|
|
let stack_size = stack_size * 2;
|
|
|
|
|
|
|
|
tokio::runtime::Builder::new_multi_thread()
|
|
|
|
.enable_all()
|
|
|
|
.thread_stack_size(stack_size)
|
|
|
|
.build()
|
|
|
|
.unwrap()
|
|
|
|
.block_on(fut)
|
2020-06-29 15:36:01 +00:00
|
|
|
}
|