UNPKG

grix-connector

Version:

Connect local AI coding agents (Claude, Codex, Gemini, Qwen, DeepSeek, Cursor, OpenCode, Pi, OpenHuman, Reasonix) to the Grix scheduling platform. Also serves as an OpenClaw plugin for Grix channel transport.

3 lines (2 loc) 796 B
import{writeFileSync as c,readFileSync as s,unlinkSync as a,existsSync as l}from"node:fs";import{join as p}from"node:path";import{GRIX_PATHS as w}from"../log/logger.js";const i=p(w.base,"grix-acp.pid");async function m(r,t){const n=Date.now()+t;for(;Date.now()<n;){try{process.kill(r,0)}catch{return!0}await new Promise(e=>setTimeout(e,100))}return!1}function y(){if(l(i)){const r=s(i,"utf-8").trim(),t=parseInt(r,10);if(!Number.isNaN(t)&&t!==process.pid)try{process.kill(t,0),process.kill(t,"SIGTERM");const n=Date.now()+3e3;let e=!0;for(;Date.now()<n;){try{process.kill(t,0)}catch{e=!1;break}const o=Date.now()+100;for(;Date.now()<o;);}if(e)try{process.kill(t,"SIGKILL")}catch{}}catch{}}c(i,`${process.pid} `,"utf-8")}function h(){try{a(i)}catch{}}export{h as removePidFile,y as writePidFile};