20 Star 70 Fork 23

TarsCloud/TarsWeb

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
execLog.js 1.35 KB
一键复制 编辑 原始数据 按行查看 历史
ruanshudong 提交于 2022-02-10 15:51 . update ui & add execLog
const CommonService = require('./k8s/service/common/CommonService');
const logger = require("./logger");
const _ = require('lodash');
const stream = require('stream');
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
let ExecLog = async (request) => {
// console.log('request', request);
let connection = request.accept('log-protocol', request.origin);
logger.info('Connection accepted');
connection.on('close', function (reasonCode, description) {
logger.info('peer ' + connection.remoteAddress + ' disconnected.');
});
let params = request.resourceURL.query;
logger.info('request:', params);
try {
const logStream = new stream.PassThrough();
logStream.on('data', (chunk) => {
// console.log('data', chunk.toString());
connection.send(chunk.toString());
})
logStream.on('close', () => {
console.log('close');
connection.close();
})
let data = await CommonService.describePod(params.podName);
logger.info('container:', data.body.spec.containers[0].name, 'podName:', params.podName);
await CommonService.readPodLog(data.body.spec.containers[0].name, params.podName, params.previous, logStream);
} catch (e) {
logger.error(e, e.statusCode);
connection.close();
}
}
module.exports = ExecLog;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/TarsCloud/TarsWeb.git
git@gitee.com:TarsCloud/TarsWeb.git
TarsCloud
TarsWeb
TarsWeb
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385