diff --git a/README.md b/README.md index faf056a..f6a5825 100644 --- a/README.md +++ b/README.md @@ -49,16 +49,10 @@ note:this demo contains many applications,please adjust your memory settings ![appactive_landscape](https://appactive.oss-cn-beijing.aliyuncs.com/images/AppActive-demo.png?x-oss-process=style/h200) #### Docker Run -1. `appactive-gateway`: `cd appactive-gateway/nginx-plugin` -> `docker build --build-arg UNITFLAG=center -t app-active/gateway:1.0-SNAPSHOT .` -2. `appactive`: maven build to get the all the jar packages: `cd ../../` -> `mvn clean package -Dmaven.test.skip -U` -3. `appactive-demo`: `cd appactive-demo` -> Run `sh run.sh` to start all applications -4. `appactive-portal`: `cd ../appactive-portal` -> Run `sh baseline.sh` to push the baseline -5. Bind the local host: `127.0.0.1 demo.appactive.io`, visit the browser `http://demo.appactive.io/listProduct?r_id=1999` to - see the effect -6. `appactive-portal`: Run `cut.sh` to cut the stream. This demo supports two cutting methods: ratio and range - - Commands: `sh cut.sh`. - - Note: the rules of the demo are hard-coded. If you want to change the cut flow range, you need to calculate the - rules by yourself, and then execute the cut flow. + +1. Run `sh run.sh` in the `appactive-demo` module to start all applications +2. Bind hosts: `127.0.0.1 demo.appactive.io`, and then visit `http://demo.appactive.io/buyProduct?r_id=2000` to see how it works +3. Run `sh cut.sh` in the `appactive-portal` module to switch flow. It should be noted that the writing-forbidden rules of this demo are hard-coded. If you want to change the range, you need to calculate the writing-forbidden rules and the next-routing rules, and then execute the flow switch. > If you plan to stop the experience, you can proceed: `cd appactive-demo` -> `docker-compose down` diff --git a/appactive-demo/run-quick.sh b/appactive-demo/run-quick.sh index d67fbe8..8af4de7 100644 --- a/appactive-demo/run-quick.sh +++ b/appactive-demo/run-quick.sh @@ -15,6 +15,10 @@ # +cd ../appactive-portal +sh baseline.sh 2 + +cd ../appactive-demo docker-compose -f docker-compose-quick.yml up -d nacos mysql sleep 20s docker-compose -f docker-compose-quick.yml up -d storage storage-unit @@ -27,6 +31,6 @@ docker-compose -f docker-compose-quick.yml up -d gateway sleep 3s cd ../appactive-portal -sh baseline.sh +sh baseline.sh 3 diff --git a/appactive-portal/baseline.sh b/appactive-portal/baseline.sh index 832e292..96a95b1 100755 --- a/appactive-portal/baseline.sh +++ b/appactive-portal/baseline.sh @@ -14,31 +14,41 @@ # limitations under the License. # -for file in $(ls ../appactive-demo/data/); do - if [[ "$file" == *"path-address"* ]]; then - echo "continue" - continue - fi - echo "$(date "+%Y-%m-%d %H:%M:%S") 应用 ${file} 基线推送中"; - cp -f ./rule/idSource.json "../appactive-demo/data/$file/" -# cp -f ./rule/idTransformer.json "../appactive-demo/data/$file/" - cp -f ./rule/transformerBetween.json "../appactive-demo/data/$file/idTransformer.json" - cp -f ./rule/idUnitMapping.json "../appactive-demo/data/$file/" - cp -f ./rule/dbProperty.json "../appactive-demo/data/$file/mysql-product" - arr=(${file//-/ }) - unitFlag=${arr[1]} - echo "{\"unitFlag\":\"${unitFlag}\"}" > "../appactive-demo/data/$file/machine.json" - echo "$(date "+%Y-%m-%d %H:%M:%S") 应用 ${file} 基线推送完成" -done +type=$1 + +if [ `expr $type % 2` == 0 ] +then + for file in $(ls ../appactive-demo/data/); do + if [[ "$file" == *"path-address"* ]]; then + echo "continue" + continue + fi + echo "$(date "+%Y-%m-%d %H:%M:%S") 应用 ${file} 基线推送中"; + cp -f ./rule/idSource.json "../appactive-demo/data/$file/" + cp -f ./rule/transformerBetween.json "../appactive-demo/data/$file/idTransformer.json" + cp -f ./rule/idUnitMapping.json "../appactive-demo/data/$file/" + cp -f ./rule/dbProperty.json "../appactive-demo/data/$file/mysql-product" + arr=(${file//-/ }) + unitFlag=${arr[1]} + echo "{\"unitFlag\":\"${unitFlag}\"}" > "../appactive-demo/data/$file/machine.json" + echo "$(date "+%Y-%m-%d %H:%M:%S") 应用 ${file} 基线推送完成" + done +fi + +if [ `expr $type % 3` == 0 ] +then + idSource=$(cat ./rule/idSource.json) + idTransformer=$(cat ./rule/idTransformer.json) + idUnitMapping=$(cat ./rule/idUnitMapping.json) + + gatewayRule="{\"idSource\" : $idSource, \"idTransformer\" : $idTransformer, \"idUnitMapping\" : $idUnitMapping}" + data="{\"key\" : \"459236fc-ed71-4bc4-b46c-69fc60d31f18_test1122\", \"value\" : $gatewayRule}" + echo $data + echo "$(date "+%Y-%m-%d %H:%M:%S") gateway 基线推送结果: " && curl --header "Content-Type: application/json" \ + --request POST \ + --data "$data" \ + 127.0.0.1:8090/set +fi + -idSource=$(cat ./rule/idSource.json) -idTransformer=$(cat ./rule/idTransformer.json) -idUnitMapping=$(cat ./rule/idUnitMapping.json) -gatewayRule="{\"idSource\" : $idSource, \"idTransformer\" : $idTransformer, \"idUnitMapping\" : $idUnitMapping}" -data="{\"key\" : \"459236fc-ed71-4bc4-b46c-69fc60d31f18_test1122\", \"value\" : $gatewayRule}" -echo $data -echo "$(date "+%Y-%m-%d %H:%M:%S") gateway 基线推送结果: " && curl --header "Content-Type: application/json" \ ---request POST \ ---data "$data" \ -127.0.0.1:8090/set diff --git a/docs/cn/details/demo.md b/docs/cn/details/demo.md index fd45d2e..301b8f2 100644 --- a/docs/cn/details/demo.md +++ b/docs/cn/details/demo.md @@ -56,10 +56,11 @@ 1. 进入 `appactive-gateway` 模块的 `nginx-plugin` 目录,将其打成镜像:`docker build --build-arg UNITFLAG=center -t app-active/gateway:1.0-SNAPSHOT .` 2. 进入 `appactive-demo` 模块,maven build 获得 jar 包 -3. 在 `appactive-demo` 模块中运行 `sh run.sh` ,启动所有应用 -4. 在 `appactive-portal` 模块中运行 `sh baseline.sh`,推送基线 -5. 绑定本地 host: `127.0.0.1 demo.appactive.io`,浏览器访问 `http://demo.appactive.io/buyProduct?r_id=2000` 查看效果 -6. 在 `appactive-portal` 模块中运行 `sh cut.sh` 进行切流。需要注意的是,本 demo 的禁写规则是写死的,用户若要更换切流范围则需自行计算禁写规则和下次路由规则,然后执行切流。 +3. 在 `appactive-portal` 模块中运行 `sh baseline.sh 2`,推送应用基线 +4. 在 `appactive-demo` 模块中运行 `sh run.sh` ,启动所有应用和网关 +5. 在 `appactive-portal` 模块中运行 `sh baseline.sh 3`,推送网关基线 +6. 绑定本地 host: `127.0.0.1 demo.appactive.io`,浏览器访问 `http://demo.appactive.io/buyProduct?r_id=2000` 查看效果 +7. 在 `appactive-portal` 模块中运行 `sh cut.sh` 进行切流。需要注意的是,本 demo 的禁写规则是写死的,用户若要更换切流范围则需自行计算禁写规则和下次路由规则,然后执行切流。 ## 规则说明 diff --git a/docs/en/details/demo.md b/docs/en/details/demo.md index 0824d5b..b7cc6ee 100644 --- a/docs/en/details/demo.md +++ b/docs/en/details/demo.md @@ -51,10 +51,11 @@ This demo requires the following software to be installed 1. Enter the nginx-plugin directory of the `appactive-gateway` module and mark it as a mirror: `docker build --build-arg UNITFLAG=center -t app-active/gateway:1.0-SNAPSHOT .` 2. Enter the `appactive-demo` module, maven build to get the jar package -3. Run `./run.sh` in the `appactive-demo` module to start all applications -4. Run `baseline.sh` in the `appactive-portal` module to push the baseline -5. Bind the local host: `127.0.0.1 demo.appactive.io`, visit the browser `http://demo.appactive.io/buyProduct?r_id=2000` to see the effect -6. Run `cut.sh` in the `appactive-portal` module to cut the flow. The cut flow commands is: `./cut.sh`. It should be noted that the write prohibition rules of this demo are hard-coded. If the user wants to change the cut flow range, he needs to calculate the write prohibition rule and the next routing rule by himself, and then execute the cut flow. +3. Run `sh baseline.sh 2` in the `appactive-portal` module to push the application baseline +4. Run `sh run.sh` in the `appactive-demo` module to start all applications and gateway +5. Run `sh baseline.sh 3` in the `appactive-portal` module to push the gateway baseline +6. Bind the local host: `127.0.0.1 demo.appactive.io`, visit the browser `http://demo.appactive.io/buyProduct?r_id=2000` to see the effect +7. Run `sh cut.sh` in the `appactive-portal` module to cut the flow. The cut flow commands is: `./cut.sh`. It should be noted that the write prohibition rules of this demo are hard-coded. If the user wants to change the cut flow range, he needs to calculate the write prohibition rule and the next routing rule by himself, and then execute the cut flow. ## Rule description