fix: restartGateway 改异步,修复 inactive 时 PIN 不闪问题
原来 removeProviderByName 内用 execSync 调 pkill,在 showPin 前 阻塞事件循环约 100ms+;若 vfdservice 是 gateway 子进程则管道无 读端,导致 showPin 写入失败或 blink setTimeout 无法触发。 改为 exec(异步):pkill 在后台执行,不阻塞事件循环,LED/VFD 操作(showPin blink)可正常调度。 Made-with: Cursor
This commit is contained in:
@@ -4,7 +4,7 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
const { execSync } = require('child_process');
|
||||
const { exec } = require('child_process');
|
||||
const log = require('./logger');
|
||||
const { resolveOpenclawConfigFile } = require('./frpc');
|
||||
|
||||
@@ -17,14 +17,18 @@ let _busy = false;
|
||||
/**
|
||||
* 终止 openclaw-gateway 进程,由 systemd --user 自动重新拉起以读取新配置。
|
||||
* 每次写盘 openclaw.json 成功后应调用一次。
|
||||
* 使用异步 exec,不阻塞 Node.js 事件循环,避免干扰 LED / VFD 等后续操作。
|
||||
*/
|
||||
function restartGateway() {
|
||||
try {
|
||||
execSync('pkill -9 -x openclaw-gateway', { timeout: 3000 });
|
||||
log.info('openclaw-provider', 'openclaw-gateway 已终止,等待自动重启');
|
||||
} catch (_) {
|
||||
log.info('openclaw-provider', 'openclaw-gateway 进程不存在,无需终止');
|
||||
}
|
||||
exec('pkill -9 -x openclaw-gateway', (err) => {
|
||||
if (err && err.code !== 1) {
|
||||
log.warn('openclaw-provider', `restartGateway: ${err.message}`);
|
||||
} else if (!err) {
|
||||
log.info('openclaw-provider', 'openclaw-gateway 已终止,等待自动重启');
|
||||
} else {
|
||||
log.info('openclaw-provider', 'openclaw-gateway 进程不存在,无需终止');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function authProfilesPathFromConfig(configFile) {
|
||||
|
||||
Reference in New Issue
Block a user