diff --git a/processor/src/app.ts b/processor/src/app.ts index 6e13a1d8c9..4da670c7ac 100644 --- a/processor/src/app.ts +++ b/processor/src/app.ts @@ -1,4 +1,5 @@ import { watch } from './watcher.js' +import { checkPartInfoHealth } from './healthChecks.js' import { createWorkers } from './workers.js' export interface KitspaceProcessorApp { @@ -14,6 +15,8 @@ export async function createApp(repoDir: string): Promise }, } + await checkPartInfoHealth() + const unwatch = await watch(repoDir) app.cleanup.push(unwatch) diff --git a/processor/src/healthChecks.ts b/processor/src/healthChecks.ts new file mode 100644 index 0000000000..770c79843b --- /dev/null +++ b/processor/src/healthChecks.ts @@ -0,0 +1,20 @@ +import fetch from 'node-fetch' + +import { log } from './log.js' + +/** + * Check the health of the partinfo.kitspace.org by checking the graphql IDE + */ +export async function checkPartInfoHealth() { + const endpoint = 'https://partinfo.kitspace.org/graphql' + const res = await fetch(endpoint, { + headers: { + accept: 'text/html', + }, + }) + if (res.status !== 200) { + throw new Error(`${endpoint} health check failed with status ${res.status}`) + } else { + log.debug(`${endpoint} health check passed`) + } +}