Commit dcef5747 authored by tywldx's avatar tywldx

debug

parent 03e967f9
...@@ -66,8 +66,19 @@ exports.initial = async function () { ...@@ -66,8 +66,19 @@ exports.initial = async function () {
await this.bindDefault(); await this.bindDefault();
let _this = this; let _this = this;
//初始化一个docker镜像 //初始化一个docker镜像
let xterm_port = await getPort(); let xterm_port,mock_port;
let mock_port = await getPort(xterm_port); let res_str = await client.getAsync(`${this.request.ip}docker`).then(function (records) {
return records
});
if(res_str == null){
xterm_port = await getPort();
mock_port = await getPort(xterm_port);
}else{
let res = JSON.parse(res_str);
xterm_port = res.xterm_port;
mock_port = res.mock_port;
}
let run_command = `docker run --privileged -d -v ${pwd}/uploads:/root/BlackPearl/uploads -p ${xterm_port}:3000 -p ${mock_port}:10086 192.168.4.36/playground/debug_image /sbin/init`; let run_command = `docker run --privileged -d -v ${pwd}/uploads:/root/BlackPearl/uploads -p ${xterm_port}:3000 -p ${mock_port}:10086 192.168.4.36/playground/debug_image /sbin/init`;
var re_str = execSync(run_command); var re_str = execSync(run_command);
console.log(run_command); console.log(run_command);
...@@ -77,8 +88,8 @@ exports.initial = async function () { ...@@ -77,8 +88,8 @@ exports.initial = async function () {
client.set(`${_this.request.ip}docker`, JSON.stringify({ client.set(`${_this.request.ip}docker`, JSON.stringify({
id: id, id: id,
is_debug: true, is_debug: true,
term_url: term_url, mock_port: mock_port,
mock_url: mock_url xterm_port: xterm_port
})); }));
spawn("sh", ["./shell_script/start_docker_image.sh", id]); spawn("sh", ["./shell_script/start_docker_image.sh", id]);
this.response.body = { term_url: term_url, mock_url: mock_url} this.response.body = { term_url: term_url, mock_url: mock_url}
...@@ -119,10 +130,20 @@ exports.stop = async function () { ...@@ -119,10 +130,20 @@ exports.stop = async function () {
let res_str = await client.getAsync(`${this.request.ip}docker`).then(function (records) { let res_str = await client.getAsync(`${this.request.ip}docker`).then(function (records) {
return records return records
}); });
console.log(res_str) // console.log(res_str)
if (res_str != null) { if (res_str != null) {
spawn("sh", ["./shell_script/stop_docker_image.sh", JSON.parse(res_str).id]); let res = JSON.parse(res_str);
client.del(`${this.request.ip}docker`); spawn("sh", ["./shell_script/stop_docker_image.sh", res.id]);
client.set(`${_this.request.ip}docker`, JSON.stringify({
id: "",
is_debug: false,
mock_port: res.mock_port,
xterm_port: res.xterm_port
}));
// client.del(`${this.request.ip}docker`);
this.response.body = { code: "0000" } this.response.body = { code: "0000" }
} else { } else {
this.response.body = { code: "0001" } this.response.body = { code: "0001" }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment