MCPcopy Create free account
hub / github.com/echoVic/blade-code / restartComponent

Method restartComponent

src/agent/ComponentManager.ts:254–279  ·  view source on GitHub ↗

* 重启组件

(id: string)

Source from the content-addressed store, hash-verified

252 * 重启组件
253 */
254 public async restartComponent(id: string): Promise<boolean> {
255 const component = this.components.get(id);
256 if (!component) {
257 return false;
258 }
259
260 try {
261 this.log(`重启组件: ${id}`);
262
263 // 销毁组件
264 await component.destroy();
265 this.emit('componentDestroyed', { id, component });
266
267 // 重新初始化组件
268 await component.init();
269 this.emit('componentInitialized', { id, component });
270
271 this.log(`组件 "${id}" 重启完成`);
272 this.emit('componentRestarted', { id, component });
273 return true;
274 } catch (error) {
275 this.log(`组件 "${id}" 重启失败: ${error}`);
276 this.emit('componentRestartFailed', { id, component, error: error as Error });
277 throw error;
278 }
279 }
280
281 /**
282 * 获取组件状态

Callers 1

demonstrateAdvancedUsageFunction · 0.80

Calls 5

logMethod · 0.95
getMethod · 0.80
destroyMethod · 0.45
emitMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected