update: print RSS in MiB at startup

main
_ 2020-12-20 18:58:14 +00:00
parent bc361fa876
commit 64ac4baaa8
3 changed files with 15 additions and 8 deletions

View File

@ -98,7 +98,7 @@ async fn main () -> Result <(), anyhow::Error> {
config_file.name.unwrap_or_else (|| "PTTH File Server".to_string ()) config_file.name.unwrap_or_else (|| "PTTH File Server".to_string ())
); );
debug! ("{:?}", instance_metrics); let gauges = metrics::Gauges::new ().await?;
let state = Arc::new (State { let state = Arc::new (State {
config: file_server::Config { config: file_server::Config {

View File

@ -1,4 +1,5 @@
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use tracing::debug;
use ulid::Ulid; use ulid::Ulid;
fn serialize_ulid <S: serde::Serializer> (t: &Ulid, s: S) fn serialize_ulid <S: serde::Serializer> (t: &Ulid, s: S)
@ -46,9 +47,13 @@ impl Gauges {
let mem = our_process.memory ().await?; let mem = our_process.memory ().await?;
let rss_mib = mem.rss ().get::<mebibyte> (); let rss_mib = mem.rss ().get::<mebibyte> ();
Ok (Gauges { let x = Gauges {
rss_mib, rss_mib,
}) };
debug! ("metric gauges: {:?}", x);
Ok (x)
} }
} }
@ -74,13 +79,17 @@ impl Startup {
#[must_use] #[must_use]
pub fn new (server_name: String) -> Self pub fn new (server_name: String) -> Self
{ {
Self { let x = Self {
machine_id: get_machine_id (), machine_id: get_machine_id (),
git_version: None, git_version: None,
server_name, server_name,
instance_id: ulid::Ulid::new (), instance_id: ulid::Ulid::new (),
startup_utc: Utc::now (), startup_utc: Utc::now (),
} };
debug! ("metrics at startup: {:?}", x);
x
} }
} }

View File

@ -215,9 +215,7 @@ pub async fn run_server (
config: Config { config: Config {
relay_url: config_file.relay_url, relay_url: config_file.relay_url,
}, },
gauges: RwLock::new (file_server::metrics::Gauges { gauges: RwLock::new (file_server::metrics::Gauges::new ().await?),
rss_mib: 7,
}),
client, client,
}); });