Skip to content

Commit fe200ce

Browse files
committed
feat: runtime
1 parent d364aac commit fe200ce

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

frameworks/Rust/hyperlane/src/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ pub(crate) use std::{fmt, hint::black_box, sync::Arc};
3232
pub(crate) use r#type::*;
3333
pub(crate) use utils::*;
3434

35-
#[tokio::main]
36-
async fn main() {
37-
init_db().await;
38-
run_server().await;
35+
fn main() {
36+
run_server();
3937
}

frameworks/Rust/hyperlane/src/server.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
use crate::*;
2+
use tokio::runtime::{Builder, Runtime};
23

3-
pub async fn run_server() {
4+
fn runtime() -> Runtime {
5+
Builder::new_multi_thread()
6+
.worker_threads(get_thread_count())
7+
.thread_stack_size(1024)
8+
.max_blocking_threads(5120)
9+
.max_io_events_per_tick(5120)
10+
.enable_all()
11+
.build()
12+
.unwrap()
13+
}
14+
15+
async fn init_server() {
416
let server: Server = Server::new();
517
server.host("0.0.0.0").await;
618
server.port(8080).await;
@@ -22,3 +34,12 @@ pub async fn run_server() {
2234
server.response_middleware(response).await;
2335
server.listen().await.unwrap();
2436
}
37+
38+
async fn init() {
39+
init_db().await;
40+
init_server().await;
41+
}
42+
43+
pub fn run_server() {
44+
runtime().block_on(init());
45+
}

0 commit comments

Comments
 (0)