1.1.1
This commit is contained in:
parent
65e44b1024
commit
c0ea480832
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -2591,7 +2591,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sr_download"
|
||||
version = "1.1.0"
|
||||
version = "1.1.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "sr_download"
|
||||
version = "1.1.0"
|
||||
version = "1.1.1"
|
||||
edition = "2021"
|
||||
default-run = "sr_download"
|
||||
|
||||
|
@ -87,6 +87,11 @@ async fn serve_mode(mut stop_receiver: Receiver<()>) -> anyhow::Result<()> {
|
||||
db_part::migrate(&db_connect).await?;
|
||||
let mut db_max_id = db_part::find_max_id(&db_connect).await;
|
||||
|
||||
let mut web_waiter = None;
|
||||
if conf.serve.enable {
|
||||
web_waiter = Some(tokio::spawn(serve::web_main()));
|
||||
}
|
||||
|
||||
event!(
|
||||
Level::INFO,
|
||||
"{}",
|
||||
@ -104,14 +109,14 @@ async fn serve_mode(mut stop_receiver: Receiver<()>) -> anyhow::Result<()> {
|
||||
// 开始等待的时间
|
||||
let mut start_wait_time = tokio::time::Instant::now();
|
||||
|
||||
let web_waiter = tokio::spawn(serve::web_main(conf));
|
||||
|
||||
loop {
|
||||
if stop_receiver.try_recv().is_ok() {
|
||||
event!(Level::INFO, "{}", "结束下载!".yellow());
|
||||
// 结束 db
|
||||
db_connect.close().await?;
|
||||
web_waiter.abort();
|
||||
if conf.serve.enable && web_waiter.is_some() {
|
||||
web_waiter.unwrap().abort();
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,9 @@ async fn get_last_ship(State(db): State<DatabaseConnection>) -> Json<Option<Last
|
||||
Json(LastShip::from_db(&db).await)
|
||||
}
|
||||
|
||||
pub async fn web_main(conf: ConfigFile) -> anyhow::Result<()> {
|
||||
pub async fn web_main() -> anyhow::Result<()> {
|
||||
let conf = crate::config::ConfigFile::try_read()?;
|
||||
|
||||
let listener = tokio::net::TcpListener::bind(conf.serve.host_with_port.clone()).await?;
|
||||
let db = db_part::connect_server(&conf).await?;
|
||||
let app = Router::new()
|
||||
|
Loading…
Reference in New Issue
Block a user