【功能完善】IoT: 增强插件启动和停止逻辑,添加异常处理,更新错误码,优化配置文件

This commit is contained in:
安浩浩
2025-02-14 09:34:25 +08:00
parent ec71cd94e8
commit 3ab7ad484a
5 changed files with 56 additions and 31 deletions

View File

@@ -65,16 +65,16 @@
</dependency>
<!-- TODO @haohao貌似不需要这个 -->
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.vertx</groupId>-->
<!-- <artifactId>vertx-web</artifactId>-->
<!-- </dependency>-->
<!-- TODO @haohao貌似 biz 模块,不需要 MQTT -->
<dependency>
<groupId>org.eclipse.paho</groupId> <!-- MQTT -->
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.eclipse.paho</groupId> &lt;!&ndash; MQTT &ndash;&gt;-->
<!-- <artifactId>org.eclipse.paho.client.mqttv3</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.pf4j</groupId> <!-- PF4J内置插件机制 -->

View File

@@ -191,13 +191,23 @@ public class IotPluginInstanceServiceImpl implements IotPluginInstanceService {
// 启动插件
if (status.equals(IotPluginStatusEnum.RUNNING.getStatus())
&& plugin.getPluginState() != PluginState.STARTED) {
pluginManager.startPlugin(pluginKey);
try {
pluginManager.startPlugin(pluginKey);
} catch (Exception e) {
log.error("[updatePluginStatus][启动插件({}) 失败]", pluginKey, e);
throw exception(ErrorCodeConstants.PLUGIN_START_FAILED, e);
}
log.info("已启动插件: {}", pluginKey);
}
// 停止插件
else if (status.equals(IotPluginStatusEnum.STOPPED.getStatus())
&& plugin.getPluginState() == PluginState.STARTED) {
pluginManager.stopPlugin(pluginKey);
try {
pluginManager.stopPlugin(pluginKey);
} catch (Exception e) {
log.error("[updatePluginStatus][停止插件({}) 失败]", pluginKey, e);
throw exception(ErrorCodeConstants.PLUGIN_STOP_FAILED, e);
}
log.info("已停止插件: {}", pluginKey);
}
}