mirror of
https://github.com/immich-app/immich.git
synced 2025-12-20 09:15:35 +03:00
feat(server): add Bash healthcheck script (#14704)
* feat(server): add Bash healthcheck script * fix(server): add 2 second timeout for healthcheck.js parity * chore(server): delete old healthcheck Node script * fix(server): feedback --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
import { ImmichWorker } from 'src/enum';
|
||||
import { ConfigRepository } from 'src/repositories/config.repository';
|
||||
|
||||
const main = async () => {
|
||||
const { host, workers, port } = new ConfigRepository().getEnv();
|
||||
if (!workers.includes(ImmichWorker.API)) {
|
||||
process.exit();
|
||||
}
|
||||
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), 2000);
|
||||
try {
|
||||
const response = await fetch(`http://${host || 'localhost'}:${port}/api/server/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