Skip to content

Commit

Permalink
update only replicas
Browse files Browse the repository at this point in the history
  • Loading branch information
Alw3ys committed Dec 18, 2023
1 parent 7347c14 commit 7f8a2d3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
16 changes: 8 additions & 8 deletions dosei/src/server/cron.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Pool<Postgres>>) {
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;
Expand Down Expand Up @@ -178,7 +178,7 @@ async fn listen_docker_events() {
_ => {}
}
}
Err(e) => error!("{:?}", e),
Err(e) => error!("Docker streaming failed: {:?}", e),
}
}
}
Expand Down
11 changes: 8 additions & 3 deletions proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 7f8a2d3

Please sign in to comment.