Search in sources :

Example 1 with SshService

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);
    }
}
Also used : SshModel(io.jpom.model.data.SshModel) SshService(io.jpom.service.node.ssh.SshService)

Example 2 with 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);
    }
}
Also used : JSONArray(com.alibaba.fastjson.JSONArray) SshService(io.jpom.service.node.ssh.SshService) JSON(com.alibaba.fastjson.JSON) File(java.io.File)

Aggregations

SshService (io.jpom.service.node.ssh.SshService)2 JSON (com.alibaba.fastjson.JSON)1 JSONArray (com.alibaba.fastjson.JSONArray)1 SshModel (io.jpom.model.data.SshModel)1 File (java.io.File)1