From 27b2b696f258b272a2bbb8824efdd3fcd0a502ff Mon Sep 17 00:00:00 2001 From: nic-chen Date: Mon, 26 Oct 2020 14:05:27 +0800 Subject: [PATCH 1/6] feat: separate build and run --- api/build-tools/schema-sync.sh | 35 ++++++++++++++++++++++++++++++++ api/build.sh | 29 ++++++++++++++++++++++++++ api/run.sh | 37 ---------------------------------- 3 files changed, 64 insertions(+), 37 deletions(-) create mode 100755 api/build-tools/schema-sync.sh create mode 100755 api/build.sh diff --git a/api/build-tools/schema-sync.sh b/api/build-tools/schema-sync.sh new file mode 100755 index 0000000000..0ac17fad66 --- /dev/null +++ b/api/build-tools/schema-sync.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +pwd=`pwd` + +version="master" +if [[ -n $1 ]]; then +version=$1 +fi + +rm -rf ./api/build-tools/apisix/ +wget https://github.com/apache/apisix/archive/$version.zip + +unzip $version.zip +mkdir -p ./api/build-tools/apisix/ +mv ./apisix-$version/apisix/* ./api/build-tools/apisix/ +rm -rf ./apisix-$version +cd ./api/build-tools/ && lua schema-sync.lua > ${pwd}/api/conf/schema.json + +echo "sync succeed:" +echo "${pwd}/api/conf/schema.json" diff --git a/api/build.sh b/api/build.sh new file mode 100755 index 0000000000..122681eca8 --- /dev/null +++ b/api/build.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +export ENV=local +pwd=`pwd` + +# get dag-to-lua lib +if [[ ! -f "dag-to-lua-1.1/lib/dag-to-lua.lua" ]]; then + wget https://github.com/api7/dag-to-lua/archive/v1.1.tar.gz + tar -zxvf v1.1.tar.gz +fi + +# build +cd ./api && go build -o ../manager-api . diff --git a/api/run.sh b/api/run.sh index a45061dc61..deced4a70b 100755 --- a/api/run.sh +++ b/api/run.sh @@ -20,44 +20,7 @@ export ENV=local pwd=`pwd` # config -cp ${pwd}/api/conf/conf_preview.json ${pwd}/conf.json export APIX_DAG_LIB_PATH="${pwd}/dag-to-lua-1.1/lib/" export APIX_ETCD_ENDPOINTS="127.0.0.1:2379" -export SYSLOG_HOST=127.0.0.1 - -if [[ "$unamestr" == 'Darwin' ]]; then - sed -i '' -e "s%#syslogAddress#%`echo $SYSLOG_HOST`%g" ${pwd}/conf.json -else - sed -i -e "s%#syslogAddress#%`echo $SYSLOG_HOST`%g" ${pwd}/conf.json -fi - -cp ${pwd}/conf.json ${pwd}/api/conf/conf.json - - -# get dag-to-lua lib -if [[ ! -f "dag-to-lua-1.1/lib/dag-to-lua.lua" ]]; then - wget https://github.com/api7/dag-to-lua/archive/v1.1.tar.gz - tar -zxvf v1.1.tar.gz -fi - - -# generate json schema if need a new one -if [[ ! -f "${pwd}/api/conf/schema.json" ]]; then - rm master.zip - rm -rf ./api/build-tools/apisix/ - wget https://github.com/apache/apisix/archive/master.zip - unzip master.zip - mkdir -p ./api/build-tools/apisix/ - mv ./apisix-master/apisix/* ./api/build-tools/apisix/ - rm -rf ./apisix-master - cd ./api/build-tools/ && lua schema-sync.lua > ${pwd}/api/conf/schema.json - cd ../../ -fi - -# build -if [[ ! -f "${pwd}/manager-api" ]]; then - cd ./api && go build -o ../manager-api . - cd ../ -fi exec ./manager-api From 841ddbe2287b3db8b0318e31ad351304e607495e Mon Sep 17 00:00:00 2001 From: nic-chen Date: Mon, 26 Oct 2020 14:40:17 +0800 Subject: [PATCH 2/6] doc: update doc about build and run --- api/build.sh | 2 ++ docs/deploy.md | 10 ++++++++-- docs/deploy.zh-CN.md | 10 ++++++++-- docs/develop.md | 15 ++++++++++++++- docs/develop.zh-CN.md | 16 +++++++++++++++- 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/api/build.sh b/api/build.sh index 122681eca8..17867a50ee 100755 --- a/api/build.sh +++ b/api/build.sh @@ -27,3 +27,5 @@ fi # build cd ./api && go build -o ../manager-api . + +echo "done." diff --git a/docs/deploy.md b/docs/deploy.md index a91dc3dbad..b6cd8558b6 100644 --- a/docs/deploy.md +++ b/docs/deploy.md @@ -61,10 +61,16 @@ export APIX_ETCD_ENDPOINTS="127.0.0.1:2379,127.0.0.1:3379" $ go env -w GOPROXY=https://goproxy.cn,direct ``` -3. Build and Run +3. Build ```sh -$ ./api/run.sh & +$ api/build.sh +``` + +4. Run + +```sh +$ api/run.sh & ``` ## Build the frontend diff --git a/docs/deploy.zh-CN.md b/docs/deploy.zh-CN.md index f8a899b6f5..24b72d1045 100644 --- a/docs/deploy.zh-CN.md +++ b/docs/deploy.zh-CN.md @@ -61,10 +61,16 @@ $ export APIX_ETCD_ENDPOINTS="127.0.0.1:2379,127.0.0.1:3379" $ go env -w GOPROXY=https://goproxy.cn,direct ``` -3. 构建并启动 +3. 构建 ```sh -$ ./api/run.sh & +$ api/build.sh +``` + +4. 启动 + +```sh +$ api/run.sh ``` ## 构建前端 diff --git a/docs/develop.md b/docs/develop.md index 2a6385c37e..a6891f920c 100644 --- a/docs/develop.md +++ b/docs/develop.md @@ -38,4 +38,17 @@ $ yarn start ## manager-api -TODO + +### Sync json schema + +To sync json schema from Apache APISIX, need to install `Lua` 5.1+ and execute the command `api/build-tools/schema-sync.sh $version`, where $version is the APISIX version number or master. Such as: + +```sh +$ api/build-tools/schema-sync.sh 2.0 +``` + +or + +```sh +$ api/build-tools/schema-sync.sh master +``` diff --git a/docs/develop.zh-CN.md b/docs/develop.zh-CN.md index 4f730944a2..a41e39c7d3 100644 --- a/docs/develop.zh-CN.md +++ b/docs/develop.zh-CN.md @@ -41,4 +41,18 @@ $ yarn start ## manager-api 开发 -待补充 + +### 同步 json schema + +从 Apache APISIX 同步 json schema ,需要安装 `Lua` 5.1+ ,并执行命令 `api/build-tools/schema-sync.sh $version` ,其中 $version 为 APISIX 版本号或 master 。如: + +```sh +$ api/build-tools/schema-sync.sh 2.0 +``` + +或 + +```sh +$ api/build-tools/schema-sync.sh master +``` + From 3a696b6021add02213eeebe32401a9907744b02c Mon Sep 17 00:00:00 2001 From: nic-chen Date: Mon, 26 Oct 2020 14:46:10 +0800 Subject: [PATCH 3/6] doc: update doc about build and run --- docs/develop.md | 2 +- docs/develop.zh-CN.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/develop.md b/docs/develop.md index a6891f920c..d28533c12b 100644 --- a/docs/develop.md +++ b/docs/develop.md @@ -41,7 +41,7 @@ $ yarn start ### Sync json schema -To sync json schema from Apache APISIX, need to install `Lua` 5.1+ and execute the command `api/build-tools/schema-sync.sh $version`, where $version is the APISIX version number or master. Such as: +To sync json schema from Apache APISIX, `Lua` 5.1+ and `zip` need to be preinstalled, and execute the command `api/build-tools/schema-sync.sh $version`, where $version is the APISIX version number or `master`. Example: ```sh $ api/build-tools/schema-sync.sh 2.0 diff --git a/docs/develop.zh-CN.md b/docs/develop.zh-CN.md index a41e39c7d3..e337d01860 100644 --- a/docs/develop.zh-CN.md +++ b/docs/develop.zh-CN.md @@ -44,7 +44,7 @@ $ yarn start ### 同步 json schema -从 Apache APISIX 同步 json schema ,需要安装 `Lua` 5.1+ ,并执行命令 `api/build-tools/schema-sync.sh $version` ,其中 $version 为 APISIX 版本号或 master 。如: +从 Apache APISIX 同步 json schema ,需要预安装 `Lua` 5.1+ 和 zip ,并执行命令 `api/build-tools/schema-sync.sh $version` ,其中 $version 为 APISIX 版本号或 master 。如: ```sh $ api/build-tools/schema-sync.sh 2.0 From 78da6fc8393fd1dd2d94989f4e200b8504b9df0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=90=9A=E8=87=B4=E8=BF=9C?= Date: Mon, 26 Oct 2020 15:38:20 +0800 Subject: [PATCH 4/6] Update schema-sync.sh --- api/build-tools/schema-sync.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/build-tools/schema-sync.sh b/api/build-tools/schema-sync.sh index 0ac17fad66..830e19c9e3 100755 --- a/api/build-tools/schema-sync.sh +++ b/api/build-tools/schema-sync.sh @@ -31,5 +31,5 @@ mv ./apisix-$version/apisix/* ./api/build-tools/apisix/ rm -rf ./apisix-$version cd ./api/build-tools/ && lua schema-sync.lua > ${pwd}/api/conf/schema.json -echo "sync succeed:" +echo "sync success:" echo "${pwd}/api/conf/schema.json" From 001eaaf95bd82c5693716a3ed093d549d5a9be50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=90=9A=E8=87=B4=E8=BF=9C?= Date: Mon, 26 Oct 2020 15:42:40 +0800 Subject: [PATCH 5/6] Update develop.md --- docs/develop.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/develop.md b/docs/develop.md index d28533c12b..54431cea59 100644 --- a/docs/develop.md +++ b/docs/develop.md @@ -38,17 +38,18 @@ $ yarn start ## manager-api +### Sync jsonschema -### Sync json schema +To sync jsonschema from Apache APISIX, `Lua` 5.1+ and `zip` need to be preinstalled, then execute this command: `api/build-tools/schema-sync.sh $version`. -To sync json schema from Apache APISIX, `Lua` 5.1+ and `zip` need to be preinstalled, and execute the command `api/build-tools/schema-sync.sh $version`, where $version is the APISIX version number or `master`. Example: +NOTE: `$version` should be `master` or Apache APISIX's version. -```sh -$ api/build-tools/schema-sync.sh 2.0 -``` - -or +Example: ```sh +# Using "master" $ api/build-tools/schema-sync.sh master + +# Using Apache APISIX's version +$ api/build-tools/schema-sync.sh 2.0 ``` From 330215b9b395e38e293e529419bd470b6824b64e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=90=9A=E8=87=B4=E8=BF=9C?= Date: Mon, 26 Oct 2020 15:45:04 +0800 Subject: [PATCH 6/6] Update develop.zh-CN.md --- docs/develop.zh-CN.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/develop.zh-CN.md b/docs/develop.zh-CN.md index e337d01860..99f02535d9 100644 --- a/docs/develop.zh-CN.md +++ b/docs/develop.zh-CN.md @@ -41,18 +41,18 @@ $ yarn start ## manager-api 开发 +### 同步 jsonschema -### 同步 json schema +从 Apache APISIX 同步 jsonschema ,需要预安装 `Lua` 5.1+ 和 `zip` ,并执行命令 `api/build-tools/schema-sync.sh $version`。 -从 Apache APISIX 同步 json schema ,需要预安装 `Lua` 5.1+ 和 zip ,并执行命令 `api/build-tools/schema-sync.sh $version` ,其中 $version 为 APISIX 版本号或 master 。如: +注意:`$version` 为 `master` 或者 Apache APISIX 的版本号。 -```sh -$ api/build-tools/schema-sync.sh 2.0 -``` - -或 +示例: ```sh +# 使用 "master" $ api/build-tools/schema-sync.sh master -``` +# 使用 Apache APISIX 的版本号 +$ api/build-tools/schema-sync.sh 2.0 +```