Skip to content

Commit 7f70585

Browse files
committed
refactor: Expose health check on a separate https port
1 parent 9501ba8 commit 7f70585

2 files changed

Lines changed: 33 additions & 15 deletions

File tree

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Point the script at stargazers' `.envrc` file.
1818

1919
When all required secrets are present, the `app-init` workflow finishes.
2020

21-
2221
## Utils
2322

2423
Launch a VM:

workflow/deployer-workflow/impl-flyio/src/lib.rs

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ const IMAGE: &str = "getobelisk/obelisk:0.25.1-ubuntu";
4343
const OBELISK_TOML_PATH: &str = formatcp!("{VOLUME_MOUNT_PATH}/obelisk.toml");
4444
const OBELISK_BIN_PATH: &str = "/obelisk/obelisk";
4545
const REGION: Region = Region::Ams;
46-
const WEBHOOK_PORT: u16 = 9090;
47-
const DEPLOYED_HEALTHCHECK_PATH: &str = "/obeliskhealthcheck";
46+
const WEBHOOK_INTERNAL_PORT: u16 = 9090;
47+
const HEALTHCHECK_INTERNAL_PORT: u16 = 9091;
48+
const HEALTHCHECK_EXTERNAL_PORT: u16 = 444;
4849

4950
fn allocate_ip(app_name: &str) -> Result<(), AppInitModifyError> {
5051
activity_fly_http::ips::allocate(
@@ -238,14 +239,26 @@ fn launch_final_vm(app_name: &str) -> Result<(), AppInitModifyError> {
238239
volume: VOLUME_NAME.to_string(),
239240
path: VOLUME_MOUNT_PATH.to_string(),
240241
}]),
241-
services: Some(vec![ServiceConfig {
242-
internal_port: WEBHOOK_PORT,
243-
protocol: ServiceProtocol::Tcp,
244-
ports: vec![PortConfig {
245-
port: 443,
246-
handlers: vec![PortHandler::Tls],
247-
}],
248-
}]),
242+
services: Some(vec![
243+
// Expose health check server as https://[::]:HEALTHCHECK_EXTERNAL_PORT
244+
ServiceConfig {
245+
internal_port: HEALTHCHECK_INTERNAL_PORT,
246+
protocol: ServiceProtocol::Tcp,
247+
ports: vec![PortConfig {
248+
port: HEALTHCHECK_EXTERNAL_PORT,
249+
handlers: vec![PortHandler::Tls],
250+
}],
251+
},
252+
// expose webhook server as default https
253+
ServiceConfig {
254+
internal_port: WEBHOOK_INTERNAL_PORT,
255+
protocol: ServiceProtocol::Tcp,
256+
ports: vec![PortConfig {
257+
port: 443,
258+
handlers: vec![PortHandler::Tls],
259+
}],
260+
},
261+
]),
249262
},
250263
Some(REGION),
251264
)
@@ -311,7 +324,7 @@ impl Guest for Component {
311324

312325
for _ in 0..max_healthcheck_attempts {
313326
match http_get::get_resp(&format!(
314-
"https://{app_name}.fly.dev{DEPLOYED_HEALTHCHECK_PATH}"
327+
"https://{app_name}.fly.dev:{HEALTHCHECK_EXTERNAL_PORT}"
315328
)) {
316329
Ok(http_get::Response {
317330
status_code,
@@ -367,6 +380,8 @@ fn get_secret_keys(config: ObeliskConfig) -> HashSet<String> {
367380
// FIXME: Insecure, use proper TOML serializer.
368381
fn serialize_obelisk_toml(config: &ObeliskConfig) -> String {
369382
const WEBHOOK_SERVER_NAME: &str = "webhook_server";
383+
const HEALTHCHECK_SERVER_NAME: &str = "healthcheck_server";
384+
370385
let mut toml_string = format!(
371386
r#"
372387
sqlite.directory = "{VOLUME_MOUNT_PATH}/obelisk-sqlite"
@@ -385,15 +400,19 @@ sqlite.pragma = {{ "cache_size" = "3000" }}
385400
enabled = true
386401
level = "WARN,obelisk=info"
387402
403+
[[http_server]]
404+
name = "{HEALTHCHECK_SERVER_NAME}"
405+
listening_addr = "0.0.0.0:{HEALTHCHECK_INTERNAL_PORT}"
406+
388407
[[webhook_endpoint]]
389408
name = "webhook_healthcheck"
390409
location.oci = "docker.io/getobelisk/components_flyio_webhook_healthcheck:2025-10-01@sha256:6fbc11b80b441ae6e642327b1ec0ceba85b2868d85dbce2d99d0d7b14a525c8c"
391-
http_server = "{WEBHOOK_SERVER_NAME}"
392-
routes = ["{DEPLOYED_HEALTHCHECK_PATH}"]
410+
http_server = "{HEALTHCHECK_SERVER_NAME}"
411+
routes = [""]
393412
394413
[[http_server]]
395414
name = "{WEBHOOK_SERVER_NAME}"
396-
listening_addr = "0.0.0.0:{WEBHOOK_PORT}"
415+
listening_addr = "0.0.0.0:{WEBHOOK_INTERNAL_PORT}"
397416
398417
"#
399418
);

0 commit comments

Comments
 (0)