1#![cfg_attr(docsrs, feature(doc_cfg))]
2#![doc = include_str!("../README.md")]
3#![warn(clippy::all, clippy::pedantic)]
4#![allow(clippy::missing_errors_doc, clippy::cast_precision_loss)]
5
6pub mod compression;
11pub mod dns;
12pub mod events;
13pub mod headers;
14pub mod json;
15pub mod middleware;
16pub mod reports;
17pub mod response;
18mod server;
19pub mod tcp;
20pub mod wasm;
21
22pub use server::*;
23
24use time::format_description::BorrowedFormatItem;
25use time::macros::format_description;
26use tokio::signal;
27
28#[cfg(target_os = "linux")]
29pub static SERVER: &str = concat!("ordinaryd/", env!("CARGO_PKG_VERSION"), " (Linux)");
30#[cfg(target_os = "macos")]
31pub static SERVER: &str = concat!("ordinaryd/", env!("CARGO_PKG_VERSION"), " (macOS)");
32#[cfg(all(unix, not(target_os = "macos"), not(target_os = "linux")))]
33pub static SERVER: &str = concat!("ordinaryd/", env!("CARGO_PKG_VERSION"), " (Unix)");
34
35#[cfg(all(not(unix), not(target_os = "macos"), not(target_os = "linux")))]
36pub static SERVER: &str = concat!("ordinaryd/", env!("CARGO_PKG_VERSION"));
37
38pub static GMT_FORMAT: &[BorrowedFormatItem<'static>] = format_description!(
39 "[weekday repr:short], [day] [month repr:short] [year] [hour]:[minute]:[second] GMT"
40);
41
42#[allow(clippy::missing_panics_doc)]
43pub async fn shutdown_signal() {
44 let ctrl_c = async {
45 signal::ctrl_c()
46 .await
47 .expect("failed to install Ctrl+C handler");
48 };
49
50 #[cfg(unix)]
51 let terminate = async {
52 signal::unix::signal(signal::unix::SignalKind::terminate())
53 .expect("failed to install signal handler")
54 .recv()
55 .await;
56 };
57
58 #[cfg(not(unix))]
59 let terminate = std::future::pending::<()>();
60
61 tokio::select! {
62 () = ctrl_c => {},
63 () = terminate => {},
64 }
65}