mirror of
https://codeberg.org/icewind/haze.git
synced 2026-10-01 08:44:09 +02:00
show information about slow starting services on start
This commit is contained in:
parent
b8c391b014
commit
5555efbfcc
5 changed files with 154 additions and 56 deletions
|
|
@ -2,13 +2,16 @@ mod oidc;
|
|||
mod saml;
|
||||
mod scim;
|
||||
|
||||
use futures_util::future::join;
|
||||
pub use oidc::AuthentikOidc;
|
||||
pub use saml::AuthentikSaml;
|
||||
pub use scim::AuthentikScim;
|
||||
use tokio::time::{sleep, timeout};
|
||||
|
||||
use crate::Result;
|
||||
use crate::cloud::CloudOptions;
|
||||
use crate::config::{HazeConfig, ProxyConfig};
|
||||
use crate::exec::exec;
|
||||
use crate::image::pull_image;
|
||||
use crate::service::ServiceTrait;
|
||||
use bollard::Docker;
|
||||
|
|
@ -19,6 +22,7 @@ use maplit::hashmap;
|
|||
use miette::{IntoDiagnostic, Report, WrapErr};
|
||||
use std::fs::{create_dir_all, write};
|
||||
use std::net::{IpAddr, Ipv4Addr};
|
||||
use std::time::Duration;
|
||||
|
||||
const AUTHENTIK_IMAGE: &str = "ghcr.io/goauthentik/server:2026.8.0";
|
||||
const POSTGRES_IMAGE: &str = "docker.io/library/postgres:16-alpine";
|
||||
|
|
@ -308,4 +312,75 @@ Authentik groups: 'authentik-group1', 'authentik-group2' and 'authentik-group3'
|
|||
"#,
|
||||
)))
|
||||
}
|
||||
|
||||
async fn final_wait(&self, docker: &Docker, cloud_id: &str) -> Result<()> {
|
||||
let server = timeout(Duration::from_mins(15), wait_server(docker, cloud_id));
|
||||
let worker = timeout(Duration::from_mins(15), wait_worker(docker, cloud_id));
|
||||
|
||||
let (server_result, worker_result) = join(server, worker).await;
|
||||
match server_result {
|
||||
Err(_) => {
|
||||
eprintln!("timeout while waiting for authentic server to become ready");
|
||||
}
|
||||
Ok(res) => res?,
|
||||
}
|
||||
match worker_result {
|
||||
Err(_) => {
|
||||
eprintln!("timeout while waiting for authentic worker to become ready");
|
||||
}
|
||||
Ok(res) => res?,
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
async fn wait_server(docker: &Docker, cloud_id: &str) -> Result<()> {
|
||||
loop {
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
if healthcheck_server(docker, cloud_id).await? {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn wait_worker(docker: &Docker, cloud_id: &str) -> Result<()> {
|
||||
loop {
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
if healthcheck_worker(docker, cloud_id).await? {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn healthcheck_server(docker: &Docker, cloud_id: &str) -> Result<bool> {
|
||||
let mut output = Vec::new();
|
||||
let exit = exec(
|
||||
docker,
|
||||
cloud_id,
|
||||
"root",
|
||||
vec!["curl", "http://authentik:9000/-/health/ready"],
|
||||
Vec::<String>::default(),
|
||||
Some(&mut output),
|
||||
)
|
||||
.await?;
|
||||
Ok(exit.is_ok())
|
||||
}
|
||||
|
||||
async fn healthcheck_worker(docker: &Docker, cloud_id: &str) -> Result<bool> {
|
||||
let container = container_name(cloud_id, "worker");
|
||||
|
||||
let mut output = Vec::new();
|
||||
let exit = exec(
|
||||
docker,
|
||||
container,
|
||||
"root",
|
||||
vec!["ak", "healthcheck"],
|
||||
Vec::<String>::default(),
|
||||
Some(&mut output),
|
||||
)
|
||||
.await?;
|
||||
Ok(exit.is_ok())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue