mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 14:54:05 +00:00
make monitor start() and stop() async
This commit is contained in:
parent
7e3734af53
commit
7f88aacbe7
2 changed files with 8 additions and 8 deletions
|
@ -199,7 +199,7 @@ class Monitor extends BeanModel {
|
||||||
* Start monitor
|
* Start monitor
|
||||||
* @param {Server} io Socket server instance
|
* @param {Server} io Socket server instance
|
||||||
*/
|
*/
|
||||||
start(io) {
|
async start(io) {
|
||||||
let previousBeat = null;
|
let previousBeat = null;
|
||||||
let retries = 0;
|
let retries = 0;
|
||||||
|
|
||||||
|
@ -836,7 +836,7 @@ class Monitor extends BeanModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Stop monitor */
|
/** Stop monitor */
|
||||||
stop() {
|
async stop() {
|
||||||
clearTimeout(this.heartbeatInterval);
|
clearTimeout(this.heartbeatInterval);
|
||||||
this.isStop = true;
|
this.isStop = true;
|
||||||
|
|
||||||
|
|
|
@ -872,7 +872,7 @@ let needSetup = false;
|
||||||
log.info("manage", `Delete Monitor: ${monitorID} User ID: ${socket.userID}`);
|
log.info("manage", `Delete Monitor: ${monitorID} User ID: ${socket.userID}`);
|
||||||
|
|
||||||
if (monitorID in server.monitorList) {
|
if (monitorID in server.monitorList) {
|
||||||
server.monitorList[monitorID].stop();
|
await server.monitorList[monitorID].stop();
|
||||||
delete server.monitorList[monitorID];
|
delete server.monitorList[monitorID];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1694,11 +1694,11 @@ async function startMonitor(userID, monitorID) {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (monitor.id in server.monitorList) {
|
if (monitor.id in server.monitorList) {
|
||||||
server.monitorList[monitor.id].stop();
|
await server.monitorList[monitor.id].stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
server.monitorList[monitor.id] = monitor;
|
server.monitorList[monitor.id] = monitor;
|
||||||
monitor.start(io);
|
await monitor.start(io);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1728,7 +1728,7 @@ async function pauseMonitor(userID, monitorID) {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (monitorID in server.monitorList) {
|
if (monitorID in server.monitorList) {
|
||||||
server.monitorList[monitorID].stop();
|
await server.monitorList[monitorID].stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1741,7 +1741,7 @@ async function startMonitors() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let monitor of list) {
|
for (let monitor of list) {
|
||||||
monitor.start(io);
|
await monitor.start(io);
|
||||||
// Give some delays, so all monitors won't make request at the same moment when just start the server.
|
// Give some delays, so all monitors won't make request at the same moment when just start the server.
|
||||||
await sleep(getRandomInt(300, 1000));
|
await sleep(getRandomInt(300, 1000));
|
||||||
}
|
}
|
||||||
|
@ -1762,7 +1762,7 @@ async function shutdownFunction(signal) {
|
||||||
log.info("server", "Stopping all monitors");
|
log.info("server", "Stopping all monitors");
|
||||||
for (let id in server.monitorList) {
|
for (let id in server.monitorList) {
|
||||||
let monitor = server.monitorList[id];
|
let monitor = server.monitorList[id];
|
||||||
monitor.stop();
|
await monitor.stop();
|
||||||
}
|
}
|
||||||
await sleep(2000);
|
await sleep(2000);
|
||||||
await Database.close();
|
await Database.close();
|
||||||
|
|
Loading…
Reference in a new issue