use of io.jpom.service.node.ssh.SshService in project Jpom by dromara.
the class ReleaseManage method doSsh.
/**
* ssh 发布
*/
private void doSsh() {
String releaseMethodDataId = this.buildExtraModule.getReleaseMethodDataId();
SshService sshService = SpringUtil.getBean(SshService.class);
List<String> strings = StrUtil.splitTrim(releaseMethodDataId, StrUtil.COMMA);
for (String releaseMethodDataIdItem : strings) {
SshModel item = sshService.getByKey(releaseMethodDataIdItem, false);
if (item == null) {
logRecorder.info("没有找到对应的ssh项:" + releaseMethodDataIdItem);
continue;
}
this.doSsh(item, sshService);
}
}
use of io.jpom.service.node.ssh.SshService in project Jpom by dromara.
the class LoadJsonConfigToDb method loadSshInfo.
public void loadSshInfo() {
File backupOldData = FileUtil.file(ConfigBean.getInstance().getDataPath(), "backup_old_data");
// 读取 ssh 文件内容
File file = FileUtil.file(ConfigBean.getInstance().getDataPath(), ServerConfigBean.SSH_LIST);
if (!FileUtil.exist(file)) {
return;
}
try {
JSON json = JsonFileUtil.readJson(file.getAbsolutePath());
JSONArray jsonArray = JsonFileUtil.formatToArray((JSONObject) json);
List<SshModel> sshModels = jsonArray.toJavaList(SshModel.class);
if (sshModels == null) {
return;
}
SshService sshService = SpringUtil.getBean(SshService.class);
sshService.insert(sshModels);
// 将 json 文件转移到备份目录
FileUtil.move(file, FileUtil.mkdir(backupOldData), true);
DefaultSystemLog.getLog().info("{} mv to {}", FileUtil.getAbsolutePath(file), FileUtil.getAbsolutePath(backupOldData));
} catch (Exception e) {
DefaultSystemLog.getLog().error("load ssh error ", e);
}
}
Aggregations