Skip to content

Commit

Permalink
Merge branch 'ag/partinfo-healthcheck' of https://github.com/kitspace…
Browse files Browse the repository at this point in the history
  • Loading branch information
Kitspace Auto-Merge Bot committed Jul 7, 2023
2 parents ff68b19 + ca1d8b8 commit 52cef0f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions processor/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { watch } from './watcher.js'
import { checkPartInfoHealth } from './healthChecks.js'
import { createWorkers } from './workers.js'

export interface KitspaceProcessorApp {
Expand All @@ -14,6 +15,8 @@ export async function createApp(repoDir: string): Promise<KitspaceProcessorApp>
},
}

await checkPartInfoHealth()

const unwatch = await watch(repoDir)
app.cleanup.push(unwatch)

Expand Down
20 changes: 20 additions & 0 deletions processor/src/healthChecks.ts
Original file line number Diff line number Diff line change
@@ -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`)
}
}

0 comments on commit 52cef0f

Please sign in to comment.