2023-08-01 21:31:45 +02:00
|
|
|
const { execSync } = require("child_process");
|
|
|
|
|
2024-05-15 10:53:41 +02:00
|
|
|
function workerHealthCheck(workerName) {
|
|
|
|
const url = `https://${workerName}.devprod-testing7928.workers.dev/secret-health-check`;
|
2023-08-01 21:31:45 +02:00
|
|
|
|
|
|
|
const buffer = execSync(`curl ${url}`);
|
|
|
|
|
|
|
|
const response = buffer.toString();
|
|
|
|
|
2023-08-11 22:36:20 +02:00
|
|
|
if (response.includes("OK")) {
|
|
|
|
console.log(`Status: Worker is up! Response: ${response}`);
|
|
|
|
} else {
|
|
|
|
throw new Error(`Worker is down! Response: ${response}`);
|
|
|
|
}
|
2023-08-01 21:31:45 +02:00
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2024-05-15 10:53:41 +02:00
|
|
|
const args = Array.from(process.argv);
|
|
|
|
const workerName = args.pop();
|
|
|
|
|
|
|
|
if (!workerName) {
|
|
|
|
throw new Error(
|
|
|
|
"Please provide the worker name as an argument when calling this program.",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
workerHealthCheck(workerName);
|