v9: minimal test with timeout + IP fallback + catch
This commit is contained in:
parent
1b84eb8c60
commit
7b7d2ac0b3
1 changed files with 27 additions and 12 deletions
|
|
@ -1,24 +1,39 @@
|
||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
// Health Sync v8 — minimal test version
|
// Health Sync v9 — minimal test with timeout + IP fallback
|
||||||
|
|
||||||
import { Script } from "scripting"
|
import { Script } from "scripting"
|
||||||
|
|
||||||
// icon-color: deep-blue; icon-glyph: heart;
|
// icon-color: deep-blue; icon-glyph: heart;
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
console.log("v8: script started")
|
console.log("v9: script started")
|
||||||
|
|
||||||
try {
|
// Try hostname first, then LAN IP
|
||||||
const response = await fetch("http://chronos:9432/health", {
|
const urls = [
|
||||||
allowInsecureRequest: true
|
"http://chronos:9432/health",
|
||||||
})
|
"http://192.168.1.148:9432/health",
|
||||||
const text = await response.text()
|
"http://100.120.136.16:9432/health"
|
||||||
console.log("v8: health check = " + text)
|
]
|
||||||
} catch (e) {
|
|
||||||
console.log("v8: fetch error = " + e)
|
for (const url of urls) {
|
||||||
|
console.log("v9: trying " + url)
|
||||||
|
try {
|
||||||
|
const response = await fetch(url, {
|
||||||
|
allowInsecureRequest: true,
|
||||||
|
timeout: 5
|
||||||
|
})
|
||||||
|
const text = await response.text()
|
||||||
|
console.log("v9: SUCCESS from " + url + " = " + text)
|
||||||
|
break
|
||||||
|
} catch (e) {
|
||||||
|
console.log("v9: FAILED " + url + " = " + e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("v8: done")
|
console.log("v9: done")
|
||||||
}
|
}
|
||||||
|
|
||||||
main().then(() => Script.exit())
|
main().then(() => Script.exit()).catch((e) => {
|
||||||
|
console.log("v9: main() error = " + e)
|
||||||
|
Script.exit()
|
||||||
|
})
|
||||||
Loading…
Add table
Reference in a new issue