Skip to content

Commit

Permalink
update salvo version
Browse files Browse the repository at this point in the history
  • Loading branch information
fankaiLiu committed Dec 6, 2023
1 parent e996ec1 commit ce44706
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
32 changes: 9 additions & 23 deletions src/template/src/main_template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use config::{CERT_KEY, CFG};
use salvo::catcher::Catcher;
use salvo::conn::rustls::{Keycert, RustlsConfig};
use salvo::prelude::*;
use tokio::sync::oneshot;
mod app_error;
{{#if need_db_conn}}
{{else}}
Expand Down Expand Up @@ -56,7 +55,6 @@ async fn main() {
{{#if is_mongodb}}
init_db_conn().await;
{{/if}}
let (tx, rx) = oneshot::channel();
let router = router();
let service: Service = router.into();
let service = service.catcher(Catcher::default().hoop(handle_404));
Expand All @@ -83,14 +81,11 @@ async fn main() {
.rustls(config)
.bind()
.await;
let server = Server::new(acceptor).serve_with_graceful_shutdown(
service,
async {
rx.await.ok();
},
None,
);
tokio::task::spawn(server);
let server = Server::new(acceptor);
let handle = server.handle();
server.serve(service).await;
handle.stop_graceful(std::time::Duration::from_secs(5));

}
false => {
println!(
Expand All @@ -103,20 +98,11 @@ async fn main() {
{{/if}}
{{/if}}
let acceptor = TcpListener::new(&CFG.server.address).bind().await;
let server = Server::new(acceptor).serve_with_graceful_shutdown(
service,
async {
rx.await.ok();
},
None,
);
tokio::task::spawn(server);
}
let server = Server::new(acceptor);
let handle = server.handle();
server.serve(service).await;
handle.stop_graceful(std::time::Duration::from_secs(5)); }
};
// Wait for Ctrl-C
tokio::signal::ctrl_c().await.unwrap();
// Then, start the shutdown...
let _ = tx.send(());
}

fn init_log() {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/create_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ pub fn write_project_file(
"jsonwebtoken": "8.3.0",
"once_cell": "1.18.0",
"salvo": {
"version": "0.59",
"version": "0.60",
"features": ["anyhow", "logging", "cors", "oapi", "jwt-auth", "rustls", "catch-panic","cookie","serve-static"]
},
"serde": "1.0.188",
Expand Down

0 comments on commit ce44706

Please sign in to comment.