Commit a8248245 authored by nanahira's avatar nanahira

add retry

parent 5d1fd754
Pipeline #250 passed with stages
in 1 minute and 15 seconds
...@@ -26,6 +26,7 @@ testDomains: ...@@ -26,6 +26,7 @@ testDomains:
- ygobbs.com # Testing sources. - ygobbs.com # Testing sources.
- nanahira.momobako.com - nanahira.momobako.com
timeout: 10000 timeout: 10000
retryCount: 3
cronString: "0 * * * * *" cronString: "0 * * * * *"
``` ```
...@@ -11,4 +11,5 @@ testDomains: ...@@ -11,4 +11,5 @@ testDomains:
- ygobbs.com # Testing sources. - ygobbs.com # Testing sources.
- nanahira.momobako.com - nanahira.momobako.com
timeout: 10000 timeout: 10000
retryCount: 3
cronString: "0 * * * * *" cronString: "0 * * * * *"
...@@ -16,6 +16,7 @@ interface Config { ...@@ -16,6 +16,7 @@ interface Config {
cdnRecords: CDNRecord[]; cdnRecords: CDNRecord[];
testDomains: string[]; testDomains: string[];
timeout: number; timeout: number;
retryCount: number;
cronString: string; cronString: string;
} }
...@@ -91,6 +92,7 @@ async function getRecords(): Promise<DomainRecordInfo[]> { ...@@ -91,6 +92,7 @@ async function getRecords(): Promise<DomainRecordInfo[]> {
async function checkNode(address: string, port: number): Promise<boolean> { async function checkNode(address: string, port: number): Promise<boolean> {
let currentTestDomain: string; let currentTestDomain: string;
for (let i = 1; i <= config.retryCount; ++i) {
try { try {
for (let testDomain of config.testDomains) { for (let testDomain of config.testDomains) {
currentTestDomain = testDomain; currentTestDomain = testDomain;
...@@ -105,9 +107,11 @@ async function checkNode(address: string, port: number): Promise<boolean> { ...@@ -105,9 +107,11 @@ async function checkNode(address: string, port: number): Promise<boolean> {
console.log(`Node ${address}:${port} is good.`); console.log(`Node ${address}:${port} is good.`);
return true; return true;
} catch (e) { } catch (e) {
console.log(`Node ${address}:${port} is bad: ${currentTestDomain} => ${e.toString()}`); console.log(`Node ${address}:${port} Failed ${i}: ${e.toString()}`);
return false; }
} }
console.log(`Node ${address}:${port} is bad.`);
return false;
} }
async function checkRecord(recordInfo: DomainRecordInfo) { async function checkRecord(recordInfo: DomainRecordInfo) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment