mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-30 10:14:03 +00:00
Compare commits
1 commit
ea8f209cab
...
15a8abb9f7
Author | SHA1 | Date | |
---|---|---|---|
|
15a8abb9f7 |
2 changed files with 7 additions and 14 deletions
|
@ -13,20 +13,16 @@ class RabbitMqMonitorType extends MonitorType {
|
|||
let baseUrls = [];
|
||||
try {
|
||||
baseUrls = JSON.parse(monitor.rabbitmqNodes);
|
||||
} catch (error) {
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error("Invalid RabbitMQ Nodes");
|
||||
}
|
||||
|
||||
heartbeat.status = DOWN;
|
||||
for (let baseUrl of baseUrls) {
|
||||
for (const baseUrl of baseUrls) {
|
||||
try {
|
||||
// Without a trailing slash, path in baseUrl will be removed. https://example.com/api -> https://example.com
|
||||
if ( !baseUrl.endsWith("/") ) {
|
||||
baseUrl += "/";
|
||||
}
|
||||
const options = {
|
||||
// Do not start with slash, it will strip the trailing slash from baseUrl
|
||||
url: new URL("api/health/checks/alarms/", baseUrl).href,
|
||||
url: new URL("/api/health/checks/alarms", baseUrl).href,
|
||||
method: "get",
|
||||
timeout: monitor.timeout * 1000,
|
||||
headers: {
|
||||
|
@ -35,8 +31,7 @@ class RabbitMqMonitorType extends MonitorType {
|
|||
},
|
||||
// Use axios signal to handle connection timeouts https://stackoverflow.com/a/74739938
|
||||
signal: axiosAbortSignal((monitor.timeout + 10) * 1000),
|
||||
// Capture reason for 503 status
|
||||
validateStatus: (status) => status === 200 || status === 503,
|
||||
validateStatus: () => true,
|
||||
};
|
||||
log.debug("monitor", `[${monitor.name}] Axios Request: ${JSON.stringify(options)}`);
|
||||
const res = await axios.request(options);
|
||||
|
@ -45,8 +40,6 @@ class RabbitMqMonitorType extends MonitorType {
|
|||
heartbeat.status = UP;
|
||||
heartbeat.msg = "OK";
|
||||
break;
|
||||
} else if (res.status === 503) {
|
||||
heartbeat.msg = res.data.reason;
|
||||
} else {
|
||||
heartbeat.msg = `${res.status} - ${res.statusText}`;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
const { describe, test } = require("node:test");
|
||||
const assert = require("node:assert");
|
||||
const { RabbitMQContainer } = require("@testcontainers/rabbitmq");
|
||||
const { RabbitMqMonitorType } = require("../../server/monitor-types/rabbitmq");
|
||||
const { UP, DOWN, PENDING } = require("../../src/util");
|
||||
const { RabbitMqMonitorType } = require("../../../server/monitor-types/rabbitmq");
|
||||
const { UP, DOWN, PENDING } = require("../../../src/util");
|
||||
|
||||
describe("RabbitMQ Single Node", {
|
||||
skip: !!process.env.CI && (process.platform !== "linux" || process.arch !== "x64"),
|
||||
|
|
Loading…
Reference in a new issue