【功能完善】IoT: 增强插件启动和停止逻辑,添加异常处理,更新错误码,优化配置文件
This commit is contained in:
@@ -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> <!– MQTT –>-->
|
||||
<!-- <artifactId>org.eclipse.paho.client.mqttv3</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.pf4j</groupId> <!-- PF4J:内置插件机制 -->
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user