fix: only set NOMAD_ALLOC_INDEX as node_id when other cluster config is present

This commit is contained in:
alyssa 2024-10-23 05:12:57 +09:00
parent 35ce4e8da2
commit 79f7c973e7
3 changed files with 8 additions and 2 deletions

View file

@ -4,7 +4,7 @@ WORKDIR /build
RUN apk add rustup build-base protoc
# todo: arm64 target
RUN rustup-init --default-host x86_64-unknown-linux-musl --default-toolchain stable --profile default -y
RUN rustup-init --default-host x86_64-unknown-linux-musl --default-toolchain nightly-2024-08-20 --profile default -y
ENV PATH=/root/.cargo/bin:$PATH
ENV RUSTFLAGS='-C link-arg=-s'

View file

@ -18,6 +18,7 @@ pub struct DiscordConfig {
pub bot_token: String,
pub client_secret: String,
pub max_concurrency: u32,
#[serde(default)]
pub cluster: Option<ClusterSettings>,
pub api_base_url: Option<String>,
@ -81,8 +82,11 @@ fn _json_log_default() -> bool {
pub struct PKConfig {
pub db: DatabaseConfig,
#[serde(default)]
pub discord: Option<DiscordConfig>,
#[serde(default)]
pub api: Option<ApiConfig>,
#[serde(default)]
pub avatars: Option<AvatarsConfig>,
#[serde(default = "_metrics_default")]
@ -105,7 +109,8 @@ impl PKConfig {
lazy_static! {
#[derive(Debug)]
pub static ref CONFIG: Arc<PKConfig> = {
if let Ok(var) = std::env::var("NOMAD_ALLOC_INDEX") {
if let Ok(var) = std::env::var("NOMAD_ALLOC_INDEX")
&& std::env::var("pluralkit__discord__cluster__total_nodes").is_ok() {
std::env::set_var("pluralkit__discord__cluster__node_id", var);
}

View file

@ -1,3 +1,4 @@
#![feature(let_chains)]
use metrics_exporter_prometheus::PrometheusBuilder;
use tracing_subscriber::EnvFilter;