metric names renamed and small fixes

This commit is contained in:
Shiroyasha 2025-02-26 23:21:15 +03:00
parent 45aa79da6d
commit b02cca8608
Signed by: shiroyashik
GPG key ID: E4953D3940D7860A
4 changed files with 18 additions and 21 deletions

View file

@ -105,6 +105,13 @@ async fn main() -> Result<()> {
},
}
// Creating avatars folder
let path = PathBuf::from(&*AVATARS_VAR);
if !path.exists() {
fs::create_dir_all(path).await.expect("Can't create avatars folder!");
tracing::info!("Created avatars directory");
}
// 4. Starting an app() that starts to serve. If app() returns true, the sculptor will be restarted. TODO: for future
loop {
if !app().await? {
@ -116,15 +123,6 @@ async fn main() -> Result<()> {
}
async fn app() -> Result<bool> {
// Preparing for launch
{
let path = PathBuf::from(&*AVATARS_VAR);
if !path.exists() {
fs::create_dir_all(path).await.expect("Can't create avatars folder!");
tracing::info!("Created avatars directory");
}
}
// Config
let config = Config::parse(CONFIG_VAR.clone().into());
let listen = config.listen.clone();
@ -198,6 +196,8 @@ async fn app() -> Result<bool> {
.nest("/api", api)
.route("/api/", get(check_auth))
.route("/ws", get(ws))
.merge(metrics::metrics_router(config.metrics_enabled))
.with_state(state)
.layer(TraceLayer::new_for_http()
// .on_request(|request: &axum::http::Request<_>, _span: &tracing::Span| {
// // only for developing purposes
@ -209,8 +209,6 @@ async fn app() -> Result<bool> {
.on_request(())
)
.layer(axum::middleware::from_fn(track_metrics))
.merge(metrics::metrics_router(config.metrics_enabled))
.with_state(state)
.route("/health", get(|| async { "ok" }));
let listener = tokio::net::TcpListener::bind(listen).await?;