支持多节点重新部署环境

This commit is contained in:
xuewei 2022-10-14 11:18:01 +08:00
parent 9d95b63b4d
commit 07da677f2f
4 changed files with 59 additions and 7 deletions

View File

@ -3,7 +3,7 @@
"displayName": "kylin-code-dist-compile",
"description": "dist compile",
"publisher": "kylinos",
"version": "0.0.1-alpha.20221011",
"version": "0.0.1-alpha.20221014",
"engines": {
"vscode": "^1.68.0"
},

View File

@ -58,6 +58,7 @@
"sshclient.createenv.failed": "Failed to generate compilation environment installation package",
"sshclient.updateenv.failed": "Failed to update the compilation environment installation package",
"sshclient.env.updated": "The compilation environment has been updated! Please redeploy the remote compilation environment",
"sshclient.env.updated.button": "Update Now",
"treeview.passwd.inputbox.placeholder": "We need to deploy the compilation environment on the host",
"treeview.passwd.inputbox.title": "Please enter the password of host {0}",
"treeview.setting.inputbox.placeholder": "Please select the compilation host",
@ -67,5 +68,7 @@
"sshclient.stop.nopid": "Compilation host stopped",
"sshclient.remove.failed": "Compilation host remove failed: {0}",
"sshclient.reinit.failed": "Compilation host reinit failed: {0}",
"extensions.system.support": "Currently, only linux is supported"
"extensions.system.support": "Currently, only linux is supported",
"treeview.add.compiler.failed": "Not found compiler! please install gcc or clang.",
"treeview.add.distcc.failed": "Cannot find distributes compilation program 'distcc'."
}

View File

@ -59,6 +59,7 @@
"sshclient.updateenv.failed": "传输编译环境安装包失败",
"sshclient.permission.denied": "编译机{0}权限被拒绝,请检查用户名密码是否正确",
"sshclient.env.updated": "检测到编译环境有更新,请更新编译主机",
"sshclient.env.updated.button": "立即更新",
"treeview.passwd.inputbox.placeholder": "我们需要在主机上部署编译环境",
"treeview.passwd.inputbox.title": "请输入主机{0}的密码",
"treeview.setting.inputbox.placeholder": "请选择编译主机",
@ -68,5 +69,7 @@
"sshclient.stop.nopid": "编译主机并未启动",
"sshclient.remove.failed": "编译主机删除失败: {0}",
"sshclient.reinit.failed": "编译主机重新初始化失败: {0}",
"extensions.system.support": "目前插件只支持linux"
"extensions.system.support": "目前插件只支持linux",
"treeview.add.compiler.failed": "系统没有安装任何编译器请安装gcc或者clang编译器",
"treeview.add.distcc.failed": "未找到分布式编译程序:'distcc'."
}

View File

@ -152,6 +152,39 @@ export class DistBuildHostManager {
this.storage()
}
public redeploy(): Promise<string[]> {
let hosts = this.getDistHosts()
return new Promise((res, rej) => {
let promises: Promise<string>[] = []
hosts.forEach((host) => {
promises.push(new Promise((res1, rej1) => {
sshclient.deployDistHost(host, (errmsg, code) => {
if (code === 100) {
res1(host.key())
} else if (code < 0) {
let err = ""
if (errmsg.indexOf("Permission denied") >= 0) {
err = localize("sshclient.permission.denied", host.key())
} else {
err = localize("sshclient.deploy.failed", host.key())
}
rej1(err)
}
})
}))
})
if (promises.length === 0) {
rej(localize('treeview.disthost.empty'))
}
Promise.all(promises).then((hostKeys) => {
res(hostKeys)
}).catch((err) => {
vscode.window.showErrorMessage(err).then(() => {
rej(err)
})
})
})
}
public deployDistHost(hostObj: def.DistBuildHostDefinition, progress: vscode.Progress<{ message?: string; increment?: number }>, token: vscode.CancellationToken): Promise<void> {
let p = new Promise<void>((res, rej) => {
token.onCancellationRequested(() => {
@ -186,17 +219,30 @@ export class DistBuildHostManager {
}
})
distBuildCmd.stderr.on('data', err => {
vscode.window.showErrorMessage(localize('treeview.add.createbuildenv.failed'))
rej(err)
})
distBuildCmd.on('error', err => {
vscode.window.showErrorMessage(localize('treeview.add.createbuildenv.failed'))
rej(err)
})
distBuildCmd.on('exit', code => {
if (code !== 0) {
vscode.window.showErrorMessage(localize('treeview.add.createbuildenv.failed'))
rej(localize('treeview.add.createbuildenv.failed'))
let errmsg = ""
switch (code) {
case 101:
errmsg = localize('treeview.add.compiler.failed')
break;
case 102:
errmsg = localize('treeview.add.distcc.failed')
break;
case 103:
errmsg = localize('treeview.add.createbuildenv.failed')
break;
default:
errmsg = localize('treeview.add.createbuildenv.failed')
}
vscode.window.showErrorMessage(errmsg)
rej(errmsg)
return
}