Commit 6c835e5b authored by tywldx's avatar tywldx

update

parent 2c96d786
var express = require('express'); var express = require('express');
var cproc = require('child_process'); var cproc = require('child_process');
var bodyParser = require('body-parser');
var execSync = cproc.execSync; var execSync = cproc.execSync;
var options = {
inflate: true,
limit: '100kb',
type: 'application/octet-stream'
};
var app = express(); var app = express();
var admin = express(); // the sub app var admin = express(); // the sub app
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
admin.get('/get_node_command/:name', function (req, res) { admin.get('/get_node_command/:name', function (req, res) {
console.log(req.params.name) console.log(req.params.name)
res.setHeader("Content-Type","application/json"); res.setHeader("Content-Type","application/json");
var str = execSync(`node ./get_project_config.js -name ${req.params.name} -attr config_file/command/gitPathHead`) var str = execSync(`node ./get_project_config.js -name ${req.params.name} -attr config_file/command/gitPathHead`)
var items = String(str).replace(/\n/g,"").split("|"); var items = String(str).replace(/\n/g,"").split("|");
var config_file = items[0].replace(/\^/g," "); var config_file = items[0].replace(/\^/g," ");
console.log(items) console.log(items)
console.log(items); console.log(items);
var command = items[1].replace(/\^/g," "); var command = items[1].replace(/\^/g," ");
var gitGroup = items[2].replace(/\^/g," "); var gitGroup = items[2].replace(/\^/g," ");
res.send({configPath:config_file,buildCmd:command,gitGroup:gitGroup});
res.send({configPath:config_file,buildCmd:command,gitGroup:gitGroup}); });
admin.post('/add_new_proxy', function (req, res) {
let request = req.body;
var str = String(execSync(`cat ../ngrok/docker_env_name.sh`));
var index = str.indexOf(request["namespace"])
if( index != -1 ){
res.send({msg:"已经存在的配置"});
return
}else{
let newstr = str + " " + request["namespace"]
//文件添加到这里面
execSync(`${newstr} > ../ngrok/docker_env_name.sh}`)
}
execSync("../ngrok/make_frp_ini.sh");
res.send({msg:"执行完成"});
});
admin.get('/get_proxy', function (req, res) {
res.setHeader("Content-Type","application/json");
var str = execSync(`cat ../ngrok/docker_env_name.sh`)
res.send({namespace:String(str)});
}); });
app.use('/config_server', admin);
app.use('/config_server', admin)
console.log("http://192.168.4.3:10088/config_server/get_node_command") console.log("http://192.168.4.3:10088/config_server/get_node_command")
app.listen(10088) app.listen(10088)
qa0 qa1
\ No newline at end of file
...@@ -2,9 +2,12 @@ ...@@ -2,9 +2,12 @@
pwd_path="/home/qa-deploy-utils/qa_shell_script" pwd_path="/home/qa-deploy-utils/qa_shell_script"
config_shell_path="$pwd_path" config_shell_path="$pwd_path"
config_server="$pwd_path/config_server" config_server="$pwd_path/config_server"
filename="/home/quant_group/frp_0.12.0_linux_amd64/frpc_custom_new_1.ini" frp_file_path="/home/quant_group/frp_0.12.0_linux_amd64"
filename="$frp_file_path/frpc_custom_new_1.ini"
nginxname="/usr/local/openresty/nginx/conf/conf.d" nginxname="/usr/local/openresty/nginx/conf/conf.d"
dockernamespace=`cat $pwd_path/ngrok/docker_env_name.sh`
ips=`cat $config_server/get_env_ip.sh` ips=`cat $config_server/get_env_ip.sh`
rm -rf $filename rm -rf $filename
function addFrpcHead() function addFrpcHead()
...@@ -143,7 +146,8 @@ function createNginxHttpAndSSLConf() ...@@ -143,7 +146,8 @@ function createNginxHttpAndSSLConf()
} }
# projectAndPort=`node $config_server/get_project_config.js -type multi -attr port`
rm -rf $nginxname/*
createNginxSSLConf store 172.30.199.2 9000 $nginxname/store.conf createNginxSSLConf store 172.30.199.2 9000 $nginxname/store.conf
for ip_last in ${ips[@]} for ip_last in ${ips[@]}
...@@ -157,16 +161,17 @@ do ...@@ -157,16 +161,17 @@ do
done done
done done
for host_name in {0..1} for host_name in ${dockernamespace[@]}
do do
projectAndPorts=`node $config_server/get_project_config.js -type multi -attr port/url -attr2 true` projectAndPorts=`node $config_server/get_project_config.js -type multi -attr port/url -attr2 true`
for projectAndPort in ${projectAndPorts[@]} for projectAndPort in ${projectAndPorts[@]}
do do
var=(${projectAndPort//|/ }) var=(${projectAndPort//|/ })
addFrpcSub ${var[0]}-${var[2]} http 127.0.0 1 8000 ${var[2]}-qa${host_name} $filename addFrpcSub ${var[0]}-${var[2]} http 127.0.0 1 8000 ${var[2]}-${host_name} $filename
createNginxHttpAndSSLConf ${var[2]}-qa${host_name} 192.168.6.6 ${var[1]} $nginxname/${var[0]}-qa${host_name}.conf createNginxHttpAndSSLConf ${var[2]}-qa${host_name} 192.168.6.6 ${var[1]} $nginxname/${var[0]}-${host_name}.conf
done done
done done
nginx -s reload
sh ${frp_file_path}/restart.sh
[store]
type = http
local_port = 127.0.0
custom_domains = 1
locations = 8001
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