RRD_CACHE: use a OnceCell instead of lazy_static
And initialize only with proxmox-backup-proxy. Other binaries dont need it. Signed-off-by: Dietmar Maurer <dietmar@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
committed by
Thomas Lamprecht
parent
1d44f175c6
commit
fa49d0fde9
@ -16,7 +16,6 @@ use proxmox_rest_server::{daemon, AuthError, ApiConfig, RestServer, RestEnvironm
|
||||
|
||||
use proxmox_backup::server::auth::check_pbs_auth;
|
||||
use proxmox_backup::auth_helpers::*;
|
||||
use proxmox_backup::RRD_CACHE;
|
||||
use proxmox_backup::config;
|
||||
|
||||
fn main() {
|
||||
@ -73,9 +72,6 @@ async fn run() -> Result<(), Error> {
|
||||
config::update_self_signed_cert(false)?;
|
||||
|
||||
proxmox_backup::server::create_run_dir()?;
|
||||
|
||||
RRD_CACHE.apply_journal()?;
|
||||
|
||||
proxmox_backup::server::jobstate::create_jobstate_dir()?;
|
||||
proxmox_backup::tape::create_tape_status_dir()?;
|
||||
proxmox_backup::tape::create_drive_state_dir()?;
|
||||
|
@ -32,7 +32,7 @@ use proxmox_rest_server::{
|
||||
};
|
||||
|
||||
use proxmox_backup::{
|
||||
RRD_CACHE,
|
||||
get_rrd_cache, initialize_rrd_cache,
|
||||
server::{
|
||||
auth::check_pbs_auth,
|
||||
jobstate::{
|
||||
@ -208,6 +208,9 @@ async fn run() -> Result<(), Error> {
|
||||
let _ = public_auth_key(); // load with lazy_static
|
||||
let _ = csrf_secret(); // load with lazy_static
|
||||
|
||||
let rrd_cache = initialize_rrd_cache()?;
|
||||
rrd_cache.apply_journal()?;
|
||||
|
||||
let mut config = ApiConfig::new(
|
||||
pbs_buildcfg::JS_DIR,
|
||||
&proxmox_backup::api2::ROUTER,
|
||||
@ -901,14 +904,18 @@ async fn run_stat_generator() {
|
||||
}
|
||||
|
||||
fn rrd_update_gauge(name: &str, value: f64) {
|
||||
if let Err(err) = RRD_CACHE.update_value(name, value, DST::Gauge) {
|
||||
eprintln!("rrd::update_value '{}' failed - {}", name, err);
|
||||
if let Ok(rrd_cache) = get_rrd_cache() {
|
||||
if let Err(err) = rrd_cache.update_value(name, value, DST::Gauge) {
|
||||
eprintln!("rrd::update_value '{}' failed - {}", name, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn rrd_update_derive(name: &str, value: f64) {
|
||||
if let Err(err) = RRD_CACHE.update_value(name, value, DST::Derive) {
|
||||
eprintln!("rrd::update_value '{}' failed - {}", name, err);
|
||||
if let Ok(rrd_cache) = get_rrd_cache() {
|
||||
if let Err(err) = rrd_cache.update_value(name, value, DST::Derive) {
|
||||
eprintln!("rrd::update_value '{}' failed - {}", name, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user