mirror of
https://github.com/immich-app/immich.git
synced 2025-12-22 17:24:56 +03:00
feat: add docker healthchecks to server and ml (#9583)
* add healthcheck * format, import, IMMICH_PORT, and eslint change * chore: clean up nodejs healthcheck * fix ruff formating * add healthcheck * format, import, IMMICH_PORT, and eslint change * chore: clean up nodejs healthcheck * fix ruff formating * add healthcheck to dockerfile * poetry run ruff check --fix * removed 2 of 3 console calls --------- Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
29
server/src/utils/healthcheck.ts
Normal file
29
server/src/utils/healthcheck.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env node
|
||||
const port = Number(process.env.IMMICH_PORT) || 3001;
|
||||
const controller = new AbortController();
|
||||
|
||||
const main = async () => {
|
||||
const timeout = setTimeout(() => controller.abort(), 2000);
|
||||
try {
|
||||
const response = await fetch(`http://localhost:${port}/api/server-info/ping`, {
|
||||
signal: controller.signal,
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const body = await response.json();
|
||||
if (body.res === 'pong') {
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof DOMException === false) {
|
||||
console.error(error);
|
||||
}
|
||||
} finally {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
|
||||
process.exit(1);
|
||||
};
|
||||
|
||||
void main();
|
||||
Reference in New Issue
Block a user