smart-house-web: в работе
This commit is contained in:
@@ -7,4 +7,4 @@ edition = "2024"
|
|||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
tracing-subscriber = "0.3"
|
tracing-subscriber = "0.3"
|
||||||
axum = "0.8"
|
axum = "0.8"
|
||||||
tokio = { version = "1.52", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1.52", features = ["rt", "rt-multi-thread", "signal"] }
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const CODE_LOGGER_INITIALIZATION_ERROR: i32 = 1;
|
|||||||
const CODE_TOKIO_RUNTIME_CREATION_ERROR: i32 = 2;
|
const CODE_TOKIO_RUNTIME_CREATION_ERROR: i32 = 2;
|
||||||
const CODE_LISTENER_BINDING_ERROR: i32 = 3;
|
const CODE_LISTENER_BINDING_ERROR: i32 = 3;
|
||||||
const CODE_STARTIG_SERVER_ERROR: i32 = 4;
|
const CODE_STARTIG_SERVER_ERROR: i32 = 4;
|
||||||
|
const CODE_CTRL_C_SIGNAL_INSTALL_ERROR: i32 = 5;
|
||||||
|
|
||||||
pub fn init_logger() {
|
pub fn init_logger() {
|
||||||
use tracing_subscriber::{Layer, layer::SubscriberExt, util::SubscriberInitExt};
|
use tracing_subscriber::{Layer, layer::SubscriberExt, util::SubscriberInitExt};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
pub fn run_server() {
|
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use tracing::{error, info};
|
use tracing::{error, info};
|
||||||
|
|
||||||
|
pub fn run_server() {
|
||||||
let runtime = match tokio::runtime::Builder::new_multi_thread()
|
let runtime = match tokio::runtime::Builder::new_multi_thread()
|
||||||
.worker_threads(2)
|
.worker_threads(2)
|
||||||
.enable_all()
|
.enable_all()
|
||||||
@@ -40,4 +40,12 @@ async fn fallback() -> axum::response::Response {
|
|||||||
(axum::http::StatusCode::NOT_FOUND, "404 NOT FOUND").into_response()
|
(axum::http::StatusCode::NOT_FOUND, "404 NOT FOUND").into_response()
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn shutdown_signal() {}
|
async fn shutdown_signal() {
|
||||||
|
let ctrl_c = match tokio::signal::ctrl_c().await {
|
||||||
|
Ok(signal) => signal,
|
||||||
|
Err(e) => {
|
||||||
|
error!("Can't install Ctrl+C signal handler: {:?}", e);
|
||||||
|
exit(crate::CODE_CTRL_C_SIGNAL_INSTALL_ERROR);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user