From 7f8a2d33d213e8ad9041eac4dc5e6c745ebe3b64 Mon Sep 17 00:00:00 2001 From: Alw3ys Date: Mon, 18 Dec 2023 16:34:39 +0100 Subject: [PATCH] update only replicas --- dosei/src/server/cron.rs | 16 ++++++++-------- proto/src/lib.rs | 11 ++++++++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/dosei/src/server/cron.rs b/dosei/src/server/cron.rs index bc803000..2f0d7c37 100644 --- a/dosei/src/server/cron.rs +++ b/dosei/src/server/cron.rs @@ -25,20 +25,20 @@ use std::error::Error; use std::str::FromStr; use std::sync::Arc; use std::time::Duration; -use tokio::io::AsyncWriteExt; +use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::TcpStream; use tokio::time::sleep; use uuid::Uuid; pub fn start_job_manager(config: &'static Config, pool: Arc>) { - tokio::spawn(async move { - loop { - sleep(Duration::from_secs(1)).await; - if config.is_replica() { + if config.is_replica() { + tokio::spawn(async move { + loop { + sleep(Duration::from_secs(1)).await; update_status(config).await.unwrap(); } - } - }); + }); + } tokio::spawn(async move { loop { run_jobs(config, Arc::clone(&pool)).await; @@ -178,7 +178,7 @@ async fn listen_docker_events() { _ => {} } } - Err(e) => error!("{:?}", e), + Err(e) => error!("Docker streaming failed: {:?}", e), } } } diff --git a/proto/src/lib.rs b/proto/src/lib.rs index fabc37df..84200b10 100644 --- a/proto/src/lib.rs +++ b/proto/src/lib.rs @@ -7,10 +7,15 @@ pub mod ping { } impl ProtoChannel for ping::Ping { - // PING const PROTO_ID: u8 = 0x00; - // Reserve for PONG - //const RESPONSE_PROTO_ID: u8 = 0x01; +} + +pub mod pong { + include!(concat!(env!("OUT_DIR"), "/dosei.cluster.rs")); +} + +impl ProtoChannel for pong::Ping { + const PROTO_ID: u8 = 0x01; } pub mod cron_job {