Skip to content

Commit

Permalink
refactor: use tokio::main instead of hand-written tokio-runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
itsusinn committed Feb 1, 2022
1 parent 7bbb6aa commit 4d199f4
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,19 @@ mod message;
mod net;
mod webhook;

fn main() {
#[tokio::main]
async fn main() {

std::backtrace::Backtrace::force_capture();
env_logger::builder()
.write_style(env_logger::WriteStyle::Auto)
.filter(None, log::LevelFilter::Warn)
.filter(None, log::LevelFilter::Error)
.format_timestamp(Some(TimestampPrecision::Seconds))
.filter(Some("telegram_message_source"), log::LevelFilter::Info)
.filter(Some("mesagisto_client"), log::LevelFilter::Info)
.filter(Some("teloxide"), log::LevelFilter::Info)
.init();
tokio::runtime::Builder::new_multi_thread()
// fixme: how many do we need
.worker_threads(5)
.enable_all()
.build()
.unwrap()
.block_on(async {
run().await.unwrap();
});

run().await.unwrap();
}
#[allow(unused_must_use)]
async fn run() -> Result<(), anyhow::Error> {
Expand Down

0 comments on commit 4d199f4

Please sign in to comment.