fix: rely on weixin health monitor instead of gateway restart
This commit is contained in:
@@ -20,7 +20,7 @@
|
|||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { execFileSync, spawnSync } = require('child_process');
|
const { execFileSync } = require('child_process');
|
||||||
const log = require('../logger');
|
const log = require('../logger');
|
||||||
|
|
||||||
// ── Constants (from reference script) ────────────────────────────────────────
|
// ── Constants (from reference script) ────────────────────────────────────────
|
||||||
@@ -69,29 +69,6 @@ function _ensureWeixinStateOwnership() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function _restartGateway() {
|
|
||||||
try {
|
|
||||||
const result = spawnSync('openclaw gateway restart', { shell: true, stdio: 'inherit' });
|
|
||||||
if (result.status !== 0) {
|
|
||||||
return {
|
|
||||||
ok: false,
|
|
||||||
code: result.status,
|
|
||||||
message: `openclaw gateway restart exited with code ${result.status}`,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
log.info('weixin', 'gateway restarted after login success');
|
|
||||||
return { ok: true };
|
|
||||||
} catch (err) {
|
|
||||||
log.warn('weixin', `gateway restart after login success failed: ${err.message}`);
|
|
||||||
return {
|
|
||||||
ok: false,
|
|
||||||
code: 1,
|
|
||||||
message: err.message,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _resolveWeixinStateDir() { return path.join(_resolveStateDir(), 'openclaw-weixin'); }
|
function _resolveWeixinStateDir() { return path.join(_resolveStateDir(), 'openclaw-weixin'); }
|
||||||
function _resolveAccountIndexPath(){ return path.join(_resolveWeixinStateDir(), 'accounts.json'); }
|
function _resolveAccountIndexPath(){ return path.join(_resolveWeixinStateDir(), 'accounts.json'); }
|
||||||
function _resolveAccountsDir() { return path.join(_resolveWeixinStateDir(), 'accounts'); }
|
function _resolveAccountsDir() { return path.join(_resolveWeixinStateDir(), 'accounts'); }
|
||||||
@@ -466,26 +443,8 @@ async function _runLogin({ callId, timeoutMs, botType, emit, isAborted }) {
|
|||||||
_registerAccountId(accountId);
|
_registerAccountId(accountId);
|
||||||
if (status.ilink_user_id) _clearStaleAccountsForUserId(accountId, status.ilink_user_id);
|
if (status.ilink_user_id) _clearStaleAccountsForUserId(accountId, status.ilink_user_id);
|
||||||
_bumpOpenClawConfigTimestamp();
|
_bumpOpenClawConfigTimestamp();
|
||||||
_ensureWeixinStateOwnership();
|
|
||||||
log.info('weixin', `callId=${callId} login success accountId=${accountId} file=${filePath}`);
|
log.info('weixin', `callId=${callId} login success accountId=${accountId} file=${filePath}`);
|
||||||
emit({ action: 'progress', event: 'login_success', data: { accountId } });
|
emit({ action: 'finish', event: 'success', data: { accountId } });
|
||||||
emit({
|
|
||||||
action: 'progress',
|
|
||||||
event: 'gateway_restarting',
|
|
||||||
data: {
|
|
||||||
status: 'restarting',
|
|
||||||
message: 'OpenClaw 正在重启,请稍候。',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const gatewayRestart = _restartGateway();
|
|
||||||
emit({
|
|
||||||
action: 'finish',
|
|
||||||
event: 'success',
|
|
||||||
data: {
|
|
||||||
accountId,
|
|
||||||
gatewayRestart,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user