hadoop-yarn-ui项目
# 背景
修改开源项目,再次自己维护;yarn列表数据接口都是一次性获取;返回数据50M左右,页面直接卡死;
改成分页获取数据;后面分页组件em-tablel
只支持客户端离线分页,不支持配合服务器分页,开发维护比较麻烦,最后
# 技术
- ember2.x, ember-cli;
- Bower, yarn;
# 安装启动
# bower 命令权限问题
解决方法有两种:
1,根据错误提示在bower命令后面加--allow-root ,例如 bower install --allow-root
2,增加一个配置文件使得运行bower时候为root权限,~/.bowerrc; {"allow_root": true }
bower install #部分要fq安装依赖;及有一些库以及没有要直接github手动下载;
yarn install # nvm use 7 使用nodejs v7.10.1
1
2
2
# 安装其他依赖
abdmob/x2js
库不存在,要在git上下载放到指定目录下;其他相关依赖,可能要fq下载安装好;
启动后,警告报错;WARNING: broccoli-babel-transpiler is opting out of caching due to a plugin that does not provide a caching strategy:
function (babel) ;处理:
npm ls babel-plugin-feature-flags`
# 开发实践
# 设置构建启动
"scripts": {
"build": "ember build --environment production",
"start": "ember server --proxy=http://10.xx.47.xx:8082",
"test": "ember test"
},
"scripts": {
"build": "TMPDIR=tmp node ./node_modules/ember-cli/bin/ember build",
"start": "TMPDIR=tmp node ./node_modules/ember-cli/bin/ember server --proxy=http://10.xx.xx.xx:8088",
"build:mvn": "TMPDIR=tmp node/node ./node_modules/ember-cli/bin/ember build -prod"
},
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
启动查看:
npm start #注意第一次启动比较慢
1
# 构建脚本
# 实现不同时区替换功能
versionDist=dist/version.json
param=zh
datePath=app/utils/date-utils.js
varKey=defaultTz
timeZone='Asia\/Shanghai'
sed -i "" "s/\($varKey =\).*/\1 '$timeZone';/" $datePath
echo "参数的值$1"
if [ $1 ]; then
param=$1
case $1 in
zh)
timeZone='Asia\/Shanghai'
;;
en)
timeZone='America\/Los_Angeles'
;;
eu)
timeZone='Europe\/London'
;;
*)
echo "param not found!!"
exit 1;
;;
esac
sed -i "" "s/\($varKey =\).*/\1 '$timeZone';/" $datePath
fi
echo "param参数的值$param"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 版本记录功能
printVersion() {
echo "==================================printVersion===================================="
curBranch=$(git show-ref | grep $(git log --pretty=%h -1) | sed 's|.*/\(.*\)|\1|' | sort -u | grep -v HEAD)
commitID=$(git rev-parse --short HEAD)
commitTime=$(git show --pretty=format:"%ci" | head -1)
buildTime=$(date "+%Y-%m-%d %H:%M:%S")
echo "{
\"version\":{
\"curBranch\": \"$curBranch\",
\"commitID\": \"$commitID\",
\"commitTime\": \"$commitTime\"
},
\"buildCfg\":{
\"buildTime\": \"$buildTime\",
\"timeZone\": \"$timeZone\"
}
}" >$versionDist
echo "=====版本记录生产version.json成功========"
cat $versionDist
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 脚本中启动调用nvm
要提前设置;
. ~/.nvm/nvm.sh
envCfg() {
echo "==================================envCfg===================================="
nvm use 7
npm i -D yarn --registry=https://registry.npm.taobao.org
node_modules/.bin/yarn config set registry https://registry.npm.taobao.org/ -g
node_modules/.bin/yarn config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/ -g
node_modules/.bin/yarn config list
}
buildPro() {
echo "==================================buildPro===================================="
# 这个项目不用做配置替换直接用的ember自带的环境
echo "=======bower使用==zip==命令========="
unzip -o zip/bower_components.zip
echo "=====项目===依赖安装中====="
node_modules/.bin/yarn install
echo "=====项目===构建中====="
node_modules/.bin/yarn build
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 定要记得WEB-INF
目录的拷贝
buildPro() {
echo "==================================buildPro===================================="
# # 这个项目不用做配置替换直接用的ember自带的环境
# echo "=======bower使用==zip==命令========="
# unzip -o zip/bower_components.zip
# echo "=====项目===依赖安装中====="
# node_modules/.bin/yarn install
# node_modules/.bin/yarn build
echo "=====项目===构建中====="
rm -rf dist/ ui2/
yarn build
}
pkgPro() {
cp -rf WEB-INF dist/
mv dist ui2
rm -rf ui2_$param.tar.gz
tar -zcvf ui2_$param.tar.gz ui2
echo "=====项目目录迁移及压缩 ui2_$param.tar.gz 成功====="
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 线上部署替换webapp/ui2
解压到usr/wdp/1.1/hadoop-yarn/webapps
目录下,替换ui2文件夹;
tar zxvf ui2_en.tar.gz
cat ui2/version.json
1
2
2
检查版本信息:
必要时清空浏览器缓存或者要重启下YARN组件,才能刷新新页面;
# 最后脚本整理
build.sh
###
# @Author: samy
# @email: yessz#foxmail.com
# @time: 2022-03-12 16:09:05
# @modAuthor: samy
# @modTime: 2022-03-15 11:41:06
# @desc:构建不同时区脚本
# Copyright © 2015~2022 BDP FE
###
set -e
. ~/.nvm/nvm.sh
versionDist=dist/version.json
param=zh
datePath=app/utils/date-utils.js
varKey=defaultTz
timeZone='Asia\/Shanghai'
sed -i "" "s/\($varKey =\).*/\1 '$timeZone';/" $datePath
echo "参数的值$1"
if [ $1 ]; then
param=$1
case $1 in
zh)
timeZone='Asia\/Shanghai'
;;
en)
timeZone='America\/Los_Angeles'
;;
eu)
timeZone='Europe\/London'
;;
*)
echo "param not found!!"
exit 1;
;;
esac
sed -i "" "s/\($varKey =\).*/\1 '$timeZone';/" $datePath
fi
echo "param参数的值$param"
envCfg() {
echo "==================================envCfg===================================="
nvm use 7
npm i -D yarn --registry=https://registry.npm.taobao.org
node_modules/.bin/yarn config set registry https://registry.npm.taobao.org/ -g
node_modules/.bin/yarn config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/ -g
node_modules/.bin/yarn config list
}
buildPro() {
echo "==================================buildPro===================================="
# 这个项目不用做配置替换直接用的ember自带的环境
echo "=======bower使用==zip==命令========="
unzip -o zip/bower_components.zip
echo "=====项目===依赖安装中====="
node_modules/.bin/yarn install
echo "=====项目===构建中====="
node_modules/.bin/yarn build
}
printVersion() {
echo "==================================printVersion===================================="
curBranch=$(git show-ref | grep $(git log --pretty=%h -1) | sed 's|.*/\(.*\)|\1|' | sort -u | grep -v HEAD)
commitID=$(git rev-parse --short HEAD)
commitTime=$(git show --pretty=format:"%ci" | head -1)
buildTime=$(date "+%Y-%m-%d %H:%M:%S")
echo "{
\"version\":{
\"curBranch\": \"$curBranch\",
\"commitID\": \"$commitID\",
\"commitTime\": \"$commitTime\"
},
\"buildCfg\":{
\"buildTime\": \"$buildTime\",
\"timeZone\": \"$timeZone\"
}
}" >$versionDist
echo "=====版本记录生产version.json成功========"
cat $versionDist
}
pkgPro() {
cp -rf WEB-INF dist/
mv dist ui2
rm -rf ui2_$param.tar.gz
tar -zcvf ui2_$param.tar.gz ui2
echo "=====项目目录迁移及压缩 ui2_$param.tar.gz 成功====="
}
envCfg
buildPro
printVersion
pkgPro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
mac环境下简化脚本:
###
# @Author: samy
# @email: yessz#foxmail.com
# @time: 2022-03-12 16:09:05
# @modAuthor: samy
# @modTime: 2022-03-17 15:12:54
# @desc:构建不同时区脚本
# Copyright © 2015~2022 BDP FE
###
set -e
. ~/.nvm/nvm.sh
versionDist=dist/version.json
param=zh
datePath=app/utils/date-utils.js
varKey=defaultTz
timeZone='Asia\/Shanghai'
# 初始化默认中文
sed -i "" "s/\($varKey =\).*/\1 '$timeZone';/" $datePath
echo "参数的值$1"
if [ $1 ]; then
param=$1
case $1 in
zh)
timeZone='Asia\/Shanghai'
;;
en)
timeZone='America\/Los_Angeles'
;;
eu)
timeZone='Europe\/London'
;;
*)
echo "param not found!!"
exit 1;
;;
esac
sed -i "" "s/\($varKey =\).*/\1 '$timeZone';/" $datePath
fi
echo "param参数的值$param"
envCfg() {
echo "==================================envCfg===================================="
nvm use 7
}
buildPro() {
echo "==================================buildPro===================================="
echo "=====项目===构建中====="
rm -rf dist/ ui2/
yarn build
}
printVersion() {
echo "==================================printVersion===================================="
curBranch=$(git show-ref | grep $(git log --pretty=%h -1) | sed 's|.*/\(.*\)|\1|' | sort -u | grep -v HEAD)
commitID=$(git rev-parse --short HEAD)
commitTime=$(git show --pretty=format:"%ci" | head -1)
buildTime=$(date "+%Y-%m-%d %H:%M:%S")
echo "{
\"version\":{
\"curBranch\": \"$curBranch\",
\"commitID\": \"$commitID\",
\"commitTime\": \"$commitTime\"
},
\"buildCfg\":{
\"buildTime\": \"$buildTime\",
\"timeZone\": \"$timeZone\"
}
}" >$versionDist
echo "=====版本记录生产version.json成功========"
cat $versionDist
}
pkgPro() {
cp -rf WEB-INF dist/
mv dist ui2
rm -rf ui2_$param.tar.gz
tar -zcvf ui2_$param.tar.gz ui2
echo "=====项目目录迁移及压缩 ui2_$param.tar.gz 成功====="
}
envCfg
buildPro
printVersion
pkgPro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
上次更新: 2023/11/17, 05:08:19