Tweak tokio worker pool, only start with main server

This commit is contained in:
timvisee 2021-11-11 12:08:10 +01:00
parent 2c5a76f92a
commit 2f3ea381b8
No known key found for this signature in database
GPG Key ID: B8DB720BC383E172
3 changed files with 12 additions and 8 deletions

View File

@ -12,7 +12,7 @@ use crate::service;
const RCON_PASSWORD_LENGTH: usize = 32;
/// Start lazymc.
pub async fn invoke(matches: &ArgMatches) -> Result<(), ()> {
pub fn invoke(matches: &ArgMatches) -> Result<(), ()> {
// Load config
#[allow(unused_mut)]
let mut config = config::load(matches);
@ -27,7 +27,7 @@ pub async fn invoke(matches: &ArgMatches) -> Result<(), ()> {
// Start server service
// TODO: start tokio runtime here?
let config = Arc::new(config);
service::server::service(config).await
service::server::service(config)
}
/// Prepare RCON.

View File

@ -29,14 +29,13 @@ use clap::App;
const LOG_DEFAULT: &str = "info";
/// Main entrypoint.
#[tokio::main]
async fn main() -> Result<(), ()> {
fn main() -> Result<(), ()> {
// Initialize logger
init_log();
// Build clap app, invoke intended action
let app = cli::app();
invoke_action(app).await
invoke_action(app)
}
/// Initialize logger.
@ -54,7 +53,7 @@ fn init_log() {
}
/// Invoke an action.
async fn invoke_action<'a>(app: App<'a>) -> Result<(), ()> {
fn invoke_action<'a>(app: App<'a>) -> Result<(), ()> {
let matches = app.get_matches();
// Config operations
@ -69,9 +68,9 @@ async fn invoke_action<'a>(app: App<'a>) -> Result<(), ()> {
return Ok(());
}
unimplemented!("Config logic here!");
unreachable!();
}
// Start server
action::start::invoke(&matches).await
action::start::invoke(&matches)
}

View File

@ -13,6 +13,11 @@ use crate::status;
use crate::util::error::{quit_error, ErrorHints};
/// Start lazymc.
///
/// Main entrypoint to start all server/status/proxy logic.
///
/// Spawns a tokio runtime to complete all work on.
#[tokio::main(flavor = "multi_thread")]
pub async fn service(config: Arc<Config>) -> Result<(), ()> {
// Load server state
let server = Arc::new(Server::default());