MCPcopy
hub / github.com/msgbyte/tianji / startMonitor

Method startMonitor

src/server/model/monitor/runner.ts:192–225  ·  view source on GitHub ↗

* Start single monitor

()

Source from the content-addressed store, hash-verified

190 * Start single monitor
191 */
192 async startMonitor() {
193 const monitor = this.monitor;
194 const { interval } = monitor;
195
196 const nextAction = () => {
197 if (this.isStopped === true) {
198 return;
199 }
200
201 this.timer = setTimeout(() => {
202 run();
203 }, interval * 1000);
204 };
205
206 const run = async () => {
207 try {
208 await this.runMonitor();
209 } catch (err) {
210 createAuditLog({
211 workspaceId: this.monitor.workspaceId,
212 relatedId: this.monitor.id,
213 relatedType: 'Monitor',
214 content: `Run monitor(id: ${monitor.id}) error: ${String(err)}`,
215 });
216 } finally {
217 nextAction();
218 }
219 };
220
221 this.isStopped = false;
222 run();
223
224 logger.info(`Start monitor ${monitor.name}(${monitor.id})`);
225 }
226
227 stopMonitor() {
228 const monitor = this.monitor;

Callers 4

restartMonitorMethod · 0.95
upsertMethod · 0.80
startAllMethod · 0.80
monitor.tsFile · 0.80

Calls 1

infoMethod · 0.65

Tested by

no test coverage detected