-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:fankaiLiu/website
- Loading branch information
Showing
233 changed files
with
783 additions
and
688 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
!.vuepress/ | ||
!.*.js | ||
.cache/ | ||
.temp/ | ||
node_modules/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
root: true, | ||
extends: 'vuepress', | ||
overrides: [ | ||
{ | ||
files: ['*.ts', '*.vue'], | ||
extends: 'vuepress-typescript', | ||
parserOptions: { | ||
project: ['tsconfig.json'], | ||
}, | ||
}, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
message="build: version %s" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,48 @@ | ||
use salvo::prelude::*; | ||
use std::time::Duration; | ||
use salvo::server::ServerHandle; | ||
use tokio::signal; | ||
|
||
#[handler] | ||
async fn hello() -> &'static str { | ||
"Hello World" | ||
} | ||
#[tokio::main] | ||
async fn main() { | ||
let acceptor = TcpListener::new("127.0.0.1:5800").bind().await; | ||
let server = Server::new(acceptor); | ||
let handle = server.handle(); | ||
|
||
// Listen Shutdown Signal | ||
tokio::spawn(listen_shutdown_signal(handle)); | ||
|
||
async fn before_shutdown(kind: &str) { | ||
tracing::info!("Received {} signal", kind); | ||
tracing::info!("Cleaning up..."); | ||
for i in (1..=3).rev() { | ||
tracing::info!("Finishing in {}...", i); | ||
tokio::time::sleep(Duration::from_secs(1)).await; | ||
} | ||
server.serve(Router::new()).await; | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
tracing_subscriber::fmt().init(); | ||
async fn listen_shutdown_signal(handle: ServerHandle) { | ||
// Wait Shutdown Signal | ||
let ctrl_c = async { | ||
signal::ctrl_c() | ||
.await | ||
.expect("failed to install Ctrl+C handler"); | ||
}; | ||
|
||
let router = Router::new().get(hello); | ||
let service = Service::new(router).hoop(Logger::new()); | ||
#[cfg(unix)] | ||
let terminate = async { | ||
signal::unix::signal(signal::unix::SignalKind::terminate()) | ||
.expect("failed to install signal handler") | ||
.recv() | ||
.await; | ||
}; | ||
|
||
let acceptor = TcpListener::new("0.0.0.0:5800").bind().await; | ||
let server = Server::new(acceptor); | ||
let handle = server.handle(); | ||
#[cfg(windows)] | ||
let terminate = async { | ||
signal::windows::ctrl_c() | ||
.expect("failed to install signal handler") | ||
.recv() | ||
.await; | ||
}; | ||
|
||
tokio::select! { | ||
_ = ctrl_c => println!("ctrl_c signal received"), | ||
_ = terminate => println!("terminate signal received"), | ||
}; | ||
|
||
// Graceful shutdown the server | ||
tokio::spawn(async move { | ||
use tokio::signal::ctrl_c; | ||
use tokio::signal::unix::{signal, SignalKind}; | ||
let mut sigterm = signal(SignalKind::terminate()).unwrap(); | ||
let mut sigint = signal(SignalKind::interrupt()).unwrap(); | ||
|
||
tokio::select! { | ||
_ = sigterm.recv() => before_shutdown("terminate").await, | ||
_ = sigint.recv() => before_shutdown("interrupt").await, | ||
_ = ctrl_c() => before_shutdown("ctrl-c").await | ||
}; | ||
handle.stop_graceful(None); | ||
}); | ||
server.serve(service).await; | ||
// Graceful Shutdown Server | ||
handle.stop_graceful(None); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.