🐛 修复批量脚本下发执行结果通知重复的bug
This commit is contained in:
parent
c063a3e588
commit
ad0984bf64
@ -103,8 +103,7 @@ module.exports = (httpServer) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// 超时未执行完成,断开连接
|
// 超时未执行完成,强制断开连接
|
||||||
disconnectAllExecClient()
|
|
||||||
const { connecting, executing } = execStatusEnum
|
const { connecting, executing } = execStatusEnum
|
||||||
execResult.forEach(item => {
|
execResult.forEach(item => {
|
||||||
// 连接中和执行中的状态设定为超时
|
// 连接中和执行中的状态设定为超时
|
||||||
@ -116,6 +115,7 @@ module.exports = (httpServer) => {
|
|||||||
asyncSendNotice('onekey_complete', '批量指令执行超时', reason)
|
asyncSendNotice('onekey_complete', '批量指令执行超时', reason)
|
||||||
socket.emit('timeout', { reason, result: execResult })
|
socket.emit('timeout', { reason, result: execResult })
|
||||||
socket.disconnect()
|
socket.disconnect()
|
||||||
|
disconnectAllExecClient()
|
||||||
}, timeout * 1000)
|
}, timeout * 1000)
|
||||||
console.log('hosts:', hosts)
|
console.log('hosts:', hosts)
|
||||||
// console.log('token:', token)
|
// console.log('token:', token)
|
||||||
@ -128,7 +128,8 @@ module.exports = (httpServer) => {
|
|||||||
socket.emit('ready')
|
socket.emit('ready')
|
||||||
let execPromise = targetHostsInfo.map((hostInfo, index) => {
|
let execPromise = targetHostsInfo.map((hostInfo, index) => {
|
||||||
// eslint-disable-next-line no-async-promise-executor
|
// eslint-disable-next-line no-async-promise-executor
|
||||||
return new Promise(async (resolve) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
|
setTimeout(() => reject('执行超时'), timeout * 1000)
|
||||||
let { authType, host, port, username } = hostInfo
|
let { authType, host, port, username } = hostInfo
|
||||||
let authInfo = { host, port, username }
|
let authInfo = { host, port, username }
|
||||||
let curRes = { command, host, name: hostInfo.name, result: '', status: execStatusEnum.connecting, date: Date.now() - (targetHostsInfo.length - index) } // , execStatusEnum
|
let curRes = { command, host, name: hostInfo.name, result: '', status: execStatusEnum.connecting, date: Date.now() - (targetHostsInfo.length - index) } // , execStatusEnum
|
||||||
@ -174,11 +175,15 @@ module.exports = (httpServer) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
await Promise.all(execPromise)
|
try {
|
||||||
consola.success('onekey执行完成')
|
await Promise.all(execPromise)
|
||||||
socket.emit('exec_complete')
|
consola.success('onekey执行完成')
|
||||||
asyncSendNotice('onekey_complete', '批量指令执行完成', '请登录面板查看执行结果')
|
socket.emit('exec_complete')
|
||||||
socket.disconnect()
|
asyncSendNotice('onekey_complete', '批量指令执行完成', '请登录面板查看执行结果')
|
||||||
|
socket.disconnect()
|
||||||
|
} catch (error) {
|
||||||
|
consola.error('onekey执行失败', error)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
socket.on('disconnect', async (reason) => {
|
socket.on('disconnect', async (reason) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user