Skip to content

Commit

Permalink
imporove healthchekcs
Browse files Browse the repository at this point in the history
  • Loading branch information
slavaGanzin committed Jan 27, 2023
1 parent d49f489 commit a7565d3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions callmemaybe.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,21 @@ const server = dns2.createServer({
});

if (includes(question.name, running)) return send(response)

setTimeout(() => {
running = without(question.name, running)
pp({running})
}, 1000) //should be healthcheck start interval
running.push(question.name)

await (c.healthcheck ? exec(c.healthcheck, {cwd: c.folder || '~', stdio: 'inherit'}) : Promise.reject({}))
.then(({stdout, stderr}) => {
running.push(question.name)
pp({healthcheck: 'ok', stdout, stderr})
})
// .then(pp)
.catch(async ({stdout, stderr}) => {
pp({healthcheck: 'fail', stdout, stderr})
running = without(question.name, running)

if (c.start) {
Expand All @@ -78,15 +88,15 @@ const server = dns2.createServer({
return await exec(c.start, {cwd: c.folder, stdio: 'inherit'})
.then(pp)
.catch(({stderr}) => {
pp({stderr, running})
pp({stderr})
onetimeServer({message: stderr, title: question.name + ' ' + c.start + ' error'})
}).then(() => {
pp({running})
send(response)
})
}
})

return send(response)

}


Expand Down

0 comments on commit a7565d3

Please sign in to comment.