Skip to content

Commit

Permalink
DSS Web installation optimization
Browse files Browse the repository at this point in the history
close #94
  • Loading branch information
chaogefeng authored and yangzhiyue committed Jan 17, 2020
1 parent e21bf3c commit bc940a3
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 44 deletions.
12 changes: 6 additions & 6 deletions web/config.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#Configuring front-end ports
dss_port="8088"
#dss web port
dss_web_port="8088"

#URL of the backend linkis gateway
linkis_url="http://localhost:20401"
#dss web access linkis gateway adress
linkis_gateway_url="http://localhost:9001"

#dss ip address
dss_ipaddr=$(ip addr | awk '/^[0-9]+: / {}; /inet.*global/ {print gensub(/(.*)\/(.*)/, "\\1", "g", $2)}')
#dss nginx ip
dss_nginx_ip=$(ip addr | awk '/^[0-9]+: / {}; /inet.*global/ {print gensub(/(.*)\/(.*)/, "\\1", "g", $2)}')
86 changes: 50 additions & 36 deletions web/install.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
#!/bin/bash

#当前路径
workDir=$(cd `dirname $0`; pwd)
shellDir=`dirname $0`
workDir=`cd ${shellDir}/..;pwd`

echo "dss web install start"

dss_web_port=$DSS_WEB_PORT
linkis_gateway_url=$LINKIS_GATEWAY_URL
dss_nginx_ip=$DSS_NGINX_IP
#linkis_eureka_url=$LINKIS_EUREKA_URL

if [[ "$dss_web_port" == "" ]]; then
source ${workDir}/conf/config.sh
fi


echo "dss front-end deployment script"

source $workDir/config.sh
# 前端放置目录,默认为解压目录
dss_basepath=$workDir

Expand Down Expand Up @@ -44,46 +54,45 @@ version=`cat /etc/redhat-release|sed -r 's/.* ([0-9]+)\..*/\1/'`

echo "========================================================================配置信息======================================================================="

echo "前端访问端口${dss_port}"
echo "后端Linkis的地址${linkis_url}"
echo "静态文件地址:${dss_basepath}/dist"
echo "当前路径${workDir}"
echo "本机ip${dss_ipaddr}"
echo "DSS web访问端口${dss_web_port}"
echo "Linkis gateway 的地址${linkis_gateway_url}"
echo "DSS web 静态文件地址:${dss_basepath}/dist"
echo "DSS web 安装路径${workDir}"
echo "DSS nginx ip${dss_nginx_ip}"

echo "========================================================================配置信息======================================================================="
echo ""


# 创建文件并配置nginx
dssConf(){

s_host='$host'
s_host='$host'
s_remote_addr='$remote_addr'
s_proxy_add_x_forwarded_for='$proxy_add_x_forwarded_for'
s_http_upgrade='$http_upgrade'
echo "
sudo sh -c "echo '
server {
listen $dss_port;# 访问端口
listen $dss_web_port;# 访问端口
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location /dss/visualis {
root ${dss_basepath}/dss/visualis; # 静态文件目录
root ${dss_basepath}; # 静态文件目录
autoindex on;
}
location / {
root ${dss_basepath}/dist; # 静态文件目录
index index.html index.html;
}
location /ws {
proxy_pass $linkis_url;#后端Linkis的地址
proxy_pass $linkis_gateway_url;#后端Linkis的地址
proxy_http_version 1.1;
proxy_set_header Upgrade $s_http_upgrade;
proxy_set_header Connection "upgrade";
}
location /api {
proxy_pass $linkis_url; #后端Linkis的地址
proxy_pass $linkis_gateway_url; #后端Linkis的地址
proxy_set_header Host $s_host;
proxy_set_header X-Real-IP $s_remote_addr;
proxy_set_header x_real_ipP $s_remote_addr;
Expand All @@ -105,7 +114,7 @@ dssConf(){
root /usr/share/nginx/html;
}
}
" > /etc/nginx/conf.d/dss.conf
' > /etc/nginx/conf.d/dss.conf"

}

Expand All @@ -114,28 +123,28 @@ centos7(){
# nginx是否安装
#sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
sudo yum install -y nginx
echo "nginx 安装成功"
sudo echo "nginx 安装成功"

# 配置nginx
dssConf

# 解决 0.0.0.0:8888 问题
yum -y install policycoreutils-python
semanage port -a -t http_port_t -p tcp $dss_port
sudo yum -y install policycoreutils-python
sudo semanage port -a -t http_port_t -p tcp $dss_web_port

# 开放前端访问端口
firewall-cmd --zone=public --add-port=$dss_port/tcp --permanent
sudo firewall-cmd --zone=public --add-port=$dss_web_port/tcp --permanent

# 重启防火墙
firewall-cmd --reload
sudo firewall-cmd --reload

# 启动nginx
systemctl restart nginx
sudo systemctl restart nginx

# 调整SELinux的参数
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
sudo sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
# 临时生效
setenforce 0
sudo setenforce 0

}

Expand All @@ -144,7 +153,7 @@ centos6(){
# yum
S_basearch='$basearch'
S_releasever='$releasever'
echo "
sudo echo "
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$E_releasever/$S_basearch/
Expand All @@ -153,31 +162,31 @@ centos6(){
" >> /etc/yum.repos.d/nginx.repo

# install nginx
yum install nginx -y
sudo yum install nginx -y

# 配置nginx
dssConf

# 防火墙
S_iptables=`lsof -i:$dss_port | wc -l`
S_iptables=`lsof -i:$dss_web_port | wc -l`
if [ "$S_iptables" -gt "0" ];then
# 已开启端口防火墙重启
service iptables restart
sudo service iptables restart
else
# 未开启防火墙添加端口再重启
iptables -I INPUT 5 -i eth0 -p tcp --dport $dss_port -m state --state NEW,ESTABLISHED -j ACCEPT
service iptables save
service iptables restart
sudo iptables -I INPUT 5 -i eth0 -p tcp --dport $dss_web_port -m state --state NEW,ESTABLISHED -j ACCEPT
sudo service iptables save
sudo service iptables restart
fi

# start
/etc/init.d/nginx start
sudo /etc/init.d/nginx start

# 调整SELinux的参数
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
sudo sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

# 临时生效
setenforce 0
sudo setenforce 0

}

Expand All @@ -190,6 +199,11 @@ fi
if [[ $version -eq 7 ]]; then
centos7
fi
echo '安装visualis前端,用户自行编译DSS前端安装包,则安装时需要把visualis的前端安装包放置于此'$dss_basepath/dss/visualis',用于自动化安装:'

if ! test -e $dss_basepath/dss/visualis/build.zip; then
echo "Error*************:用户自行编译安装DSS WEB时,则需要把visualis的前端安装包build.zip放置于$dss_basepath/dss/visualis用于自动化安装"
exit 1
fi

cd $dss_basepath/dss/visualis;unzip -o build.zip > /dev/null
echo "请浏览器访问:http://${dss_ipaddr}:${dss_port}"
#echo "请浏览器访问:http://${dss_nginx_ip}:${dss_web_port}"
4 changes: 2 additions & 2 deletions web/vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ module.exports = {
onEnd: {
copy: [
{ source: 'node_modules/monaco-editor/dev/vs', destination: `./dist/dist/static/vs` },
{ source: './config.sh', destination: `./dist` },
{ source: './install.sh', destination: `./dist` }
{ source: './config.sh', destination: `./dist/conf` },
{ source: './install.sh', destination: `./dist/bin` }
],
// 先删除根目录下的zip包
delete: [`./wedatasphere-DataSphereStudio-${getVersion()}-dist.zip`],
Expand Down

0 comments on commit bc940a3

Please sign in to comment.