Skip to main content
Glama

stop_monitor

Terminate a persistent monitoring process for Valkey or Redis instances to stop ongoing observability data collection.

Instructions

Stop a persistent BetterDB monitor process that was previously started with start_monitor or --autostart --persist.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The implementation of the stopMonitor function, which checks for the monitor PID file, kills the process if it's running, and cleans up the PID file.
    export async function stopMonitor(): Promise<{ stopped: boolean; message: string }> {
      if (!fs.existsSync(PID_FILE)) {
        return { stopped: false, message: 'No persisted monitor found.' };
      }
      const pid = readValidPid(PID_FILE);
      if (pid === null) {
        try { fs.unlinkSync(PID_FILE); } catch { /* ignore */ }
        return { stopped: true, message: 'Removed corrupted PID file.' };
      }
      let wasRunning = false;
      try {
        process.kill(pid, 0);
        wasRunning = true;
        process.kill(pid, 'SIGTERM');
      } catch {
        // Process not running — stale PID file
      }
    
      if (wasRunning) {
        // Wait for process to actually exit (up to 5s)
        const deadline = Date.now() + 5_000;
        while (Date.now() < deadline) {
          try { process.kill(pid, 0); } catch { break; }
          await new Promise(resolve => setTimeout(resolve, 250));
        }
      }
    
      try { fs.unlinkSync(PID_FILE); } catch { /* already removed */ }
      return wasRunning
        ? { stopped: true, message: `Stopped monitor (PID ${pid}).` }
        : { stopped: true, message: `Removed stale PID file (process ${pid} was not running).` };
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/BetterDB-inc/monitor'

If you have feedback or need assistance with the MCP directory API, please join our Discord server