Skip to content

Commit

Permalink
Add endpoint for k8s probing. (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
r12f authored Aug 7, 2022
1 parent 20a7633 commit 278c471
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions build/azure-pipeline/workflow-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ pr:
- divoom/Cargo.toml
- divoom_cli/src
- divoom_cli/Cargo.toml
- divoom_gateway/src
- divoom_gateway/Cargo.toml

#
# Version and jobs
Expand Down
10 changes: 8 additions & 2 deletions divoom_gateway/src/server/api_server.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::api_handler::*;
use divoom::DivoomAnimationTemplateManager;
use poem::{listener::TcpListener, Route};
use poem::{listener::TcpListener, Route, handler};
use poem_openapi::OpenApiService;
use std::sync::Arc;

Expand Down Expand Up @@ -45,10 +45,16 @@ impl ApiServer {
let app = Route::new()
.nest("/api", api_service)
.nest("/openapi.json", spec)
.nest("/", ui);
.nest("/", ui)
.at("/probe", poem::get(probe));

let server_endpoint = format!("{}:{}", self.server_address, self.server_port);
let server_listener = TcpListener::bind(server_endpoint);
poem::Server::new(server_listener).run(app).await
}
}

#[handler]
fn probe() -> String {
"ok".to_string()
}

0 comments on commit 278c471

Please sign in to comment.