Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
fix problem with dns (tokio spawn)
Browse files Browse the repository at this point in the history
  • Loading branch information
TOwInOK committed Apr 25, 2024
1 parent 9e54402 commit 68645ec
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
14 changes: 11 additions & 3 deletions config.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
[core]
name = "vanilla"
path = ""
name = "purpur"
version = "1.20.4"
build = "2176"
path = "core/purpur.jar"

[plugins]
[plugins.chunky]
version = "iwsbfPGg"
path = "plugins/chunky.jar"

[plugins.simple-voice-chat]
version = "B23zGLmw"
path = "plugins/simple-voice-chat.jar"
5 changes: 4 additions & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub mod core;
mod models;
pub mod plugins;

use crate::errors::error::Result;
use crate::{downloader::hash::ChooseHash, errors::error::Result};
use additions::Additions;
use core::Core;
use log::info;
Expand Down Expand Up @@ -39,4 +39,7 @@ impl Config {

Ok(config)
}
pub async fn get_core_link(self) -> Result<(String, ChooseHash, String)> {
self.core.get_link().await
}
}
1 change: 1 addition & 0 deletions src/config/models/extensions/modrinth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl ModelExtensions for ModrinthData {
) -> Result<(String, crate::downloader::hash::ChooseHash, String)> {
let loader = "fabric";
let link: String = {
// TODO: Make normal params!
match game_version {
Some(game_version) => {
let channel = plugin.channel.get_str().await;
Expand Down
11 changes: 6 additions & 5 deletions src/controller/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{sync::Arc, time::Duration};

use log::{error, info, trace};
use log::{debug, error, info, trace};
use tokio::{sync::Mutex, time::sleep};
use tokio_util::sync::CancellationToken;

Expand All @@ -21,11 +21,12 @@ impl Controller {

let config = Arc::clone(&controller.config);
let lock = Arc::clone(&controller.lock);
tokio::spawn(async move {
let c = tokio::spawn(async move {
run(config, lock, &token).await;
});
let _ = tokio::try_join!(c).unwrap();

watch_config_changes(&token_clone).await
// watch_config_changes(&token_clone).await
}

async fn new() -> Result<Self> {
Expand Down Expand Up @@ -91,14 +92,14 @@ async fn start(config: &Arc<Mutex<Config>>, lock: &Arc<Mutex<Lock>>) {

async fn run(config: Arc<Mutex<Config>>, lock: Arc<Mutex<Lock>>, token: &CancellationToken) {
// let sleep_cooldown = self.config.lock().await.additions.time_to_await;
let cooldown = 100;
let cooldown = 600f32;
loop {
info!("Start checking and download");
start(&config, &lock).await;

// Sleep for 5 minutes
tokio::select! {
_ = sleep(Duration::from_millis(cooldown)) => {},
_ = sleep(Duration::from_secs_f32(cooldown)) => {},
_ = token.cancelled() => break,
};
}
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ async fn main() {
pretty_env_logger::formatted_builder()
.filter_level(log::LevelFilter::Trace)
.init();

controller::Controller::init().await
}

0 comments on commit 68645ec

Please sign in to comment.