You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2023/02/06 12:46:51 UTC

[servicecomb-kie] branch master updated: [fix]start kie:latest container failed (#277)

This is an automated email from the ASF dual-hosted git repository.

littlecui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git


The following commit(s) were added to refs/heads/master by this push:
     new b25047c  [fix]start kie:latest container failed (#277)
b25047c is described below

commit b25047c2975bed648e51b7a50a9570b2ddc9aa31
Author: little-cui <su...@qq.com>
AuthorDate: Mon Feb 6 20:46:46 2023 +0800

    [fix]start kie:latest container failed (#277)
---
 build/build_binary.sh          | 45 +++++++++++++----------------
 build/docker/server/Dockerfile |  3 +-
 cmd/kieserver/main.go          |  1 +
 examples/dev/conf/chassis.yaml |  7 ++++-
 examples/dev/conf/lager.yaml   |  4 ++-
 examples/dev/kie-conf.yaml     |  3 +-
 scripts/start.sh               | 65 ++++++++++++++++++++----------------------
 7 files changed, 64 insertions(+), 64 deletions(-)

diff --git a/build/build_binary.sh b/build/build_binary.sh
index 32d23e4..fabd577 100755
--- a/build/build_binary.sh
+++ b/build/build_binary.sh
@@ -13,10 +13,11 @@
 # 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.
+
 echo "GOPATH is "${GOPATH}
 export BUILD_DIR=$(cd "$(dirname "$0")"; pwd)
 export PROJECT_DIR=$(dirname ${BUILD_DIR})
-export CGO_ENABLED=${CGO_ENABLED:-0} # prevent to compile cgo file
+export CGO_ENABLED=${CGO_ENABLED:-0}               # prevent to compile cgo file
 export GO_EXTLINK_ENABLED=${GO_EXTLINK_ENABLED:-0} # do not use host linker
 export GO_LDFLAGS=${GO_LDFLAGS:-" -s -w"}
 echo "downloading dependencies"
@@ -26,27 +27,23 @@ version="latest"
 release_dir=${PROJECT_DIR}/release/kie
 
 if [ -z "${VERSION}" ]; then
- echo "missing VERSION env, use ${version} as release version"
+  echo "missing VERSION env, use ${version} as release version"
 else
- version=${VERSION}
+  version=${VERSION}
 fi
 
 if [ -d ${release_dir} ]; then
-    rm -rf ${release_dir}
+  rm -rf ${release_dir}
 fi
 
 mkdir -p ${release_dir}/conf
 
-
-export GIT_COMMIT=`git rev-parse HEAD | cut -b 1-7`
+export GIT_COMMIT=$(git rev-parse HEAD | cut -b 1-7)
 echo "build from ${GIT_COMMIT}"
 
-
-
-
-writeConfig(){
-echo "write chassis config..."
-cat <<EOM > ${release_dir}/conf/chassis.yaml
+writeConfig() {
+  echo "write chassis config..."
+  cat <<EOM >${release_dir}/conf/chassis.yaml
 servicecomb:
   registry:
     disabled: true
@@ -56,20 +53,20 @@ servicecomb:
   handler:
     chain:
       Provider:
-        default: ratelimiter-provider,monitoring,jwt,track-handler
+        default: access-log,monitoring,jwt,track-handler,traffic-marker,rate-limiter
 EOM
-echo "write miroservice config..."
-cat <<EOM > ${release_dir}/conf/microservice.yaml
+  echo "write miroservice config..."
+  cat <<EOM >${release_dir}/conf/microservice.yaml
 servicecomb:
   service:
     name: servicecomb-kie
     version: ${version}
 EOM
 
-cat <<EOM > ${release_dir}/conf/kie-conf.yaml
+  cat <<EOM >${release_dir}/conf/kie-conf.yaml
 db:
+  kind: mongo
   uri: mongodb://root:root@127.0.0.1:27017/servicecomb
-  type: mongodb
   poolSize: 10
   ssl: false
   sslCA:
@@ -84,31 +81,29 @@ rm -f ${release_dir}/licenses/LICENSE ${release_dir}/licenses/NOTICE
 cd ${release_dir}
 component="apache-servicecomb-kie"
 
-buildAndPackage(){
+buildAndPackage() {
   GOOS=$1
   GOARCH=$2
   echo "building & packaging ${GOOS} ${GOARCH}..."
   if [ "$GOOS" = "windows" ]; then
-     GOOS=${GOOS} GOARCH=${GOARCH} go build --ldflags "${GO_LDFLAGS}" -o ${release_dir}/kie.exe github.com/apache/servicecomb-kie/cmd/kieserver
+    GOOS=${GOOS} GOARCH=${GOARCH} go build --ldflags "${GO_LDFLAGS}" -o ${release_dir}/kie.exe github.com/apache/servicecomb-kie/cmd/kieserver
   else
-     GOOS=${GOOS} GOARCH=${GOARCH} go build --ldflags "${GO_LDFLAGS}" -o ${release_dir}/kie github.com/apache/servicecomb-kie/cmd/kieserver
+    GOOS=${GOOS} GOARCH=${GOARCH} go build --ldflags "${GO_LDFLAGS}" -o ${release_dir}/kie github.com/apache/servicecomb-kie/cmd/kieserver
   fi
 
   if [ $? -eq 0 ]; then
     if [ "$GOOS" = "windows" ]; then
-       tar zcf "$component-$VERSION-${GOOS}-${GOARCH}.tar.gz" conf kie.exe LICENSE NOTICE licenses
+      tar zcf "$component-$version-${GOOS}-${GOARCH}.tar.gz" conf kie.exe LICENSE NOTICE licenses
     else
-       tar zcf "$component-$VERSION-${GOOS}-${GOARCH}.tar.gz" conf kie LICENSE NOTICE licenses
+      tar zcf "$component-$version-${GOOS}-${GOARCH}.tar.gz" conf kie LICENSE NOTICE licenses
     fi
   else
     echo -e "\033[31m build ${GOOS}-${GOARCH} fail !! \033[0m"
   fi
 }
 
-for GOOS in 'windows' 'darwin' 'linux'
-do
+for GOOS in 'windows' 'darwin' 'linux'; do
   buildAndPackage $GOOS "amd64"
 done
 
 buildAndPackage "linux" "arm64"
-
diff --git a/build/docker/server/Dockerfile b/build/docker/server/Dockerfile
index db149b0..611d364 100644
--- a/build/docker/server/Dockerfile
+++ b/build/docker/server/Dockerfile
@@ -15,7 +15,8 @@
 
 FROM alpine:latest
 
-RUN mkdir -p /etc/servicecomb-kie/
+WORKDIR /opt/servicecomb-kie
+
 RUN mkdir -p /opt/servicecomb-kie/conf
 
 ADD ./kie /opt/servicecomb-kie/
diff --git a/cmd/kieserver/main.go b/cmd/kieserver/main.go
index 2572f08..f993643 100644
--- a/cmd/kieserver/main.go
+++ b/cmd/kieserver/main.go
@@ -26,6 +26,7 @@ import (
 
 	//custom handlers
 	_ "github.com/apache/servicecomb-kie/server/handler"
+	_ "github.com/go-chassis/go-chassis/v2/middleware/accesslog"
 	_ "github.com/go-chassis/go-chassis/v2/middleware/monitoring"
 	_ "github.com/go-chassis/go-chassis/v2/middleware/ratelimiter"
 
diff --git a/examples/dev/conf/chassis.yaml b/examples/dev/conf/chassis.yaml
index f583253..c935932 100755
--- a/examples/dev/conf/chassis.yaml
+++ b/examples/dev/conf/chassis.yaml
@@ -6,10 +6,15 @@ servicecomb:
   protocols:
     rest:
       listenAddress: 127.0.0.1:30110
+  rateLimiting:
+    global: |
+      match: none
+      rate: 200
+      burst: 200
   handler:
     chain:
       Provider:
-        default: ratelimiter-provider,monitoring,jwt,track-handler
+        default: access-log,monitoring,jwt,track-handler,traffic-marker,rate-limiter
   transport:
     maxBodyBytes:
       rest: 2621440 #2.5M
diff --git a/examples/dev/conf/lager.yaml b/examples/dev/conf/lager.yaml
index 1d238c0..617e4a7 100644
--- a/examples/dev/conf/lager.yaml
+++ b/examples/dev/conf/lager.yaml
@@ -1 +1,3 @@
-logLevel: DEBUG
\ No newline at end of file
+logWriters: stdout
+logLevel: DEBUG
+accessLogFile: stdout
\ No newline at end of file
diff --git a/examples/dev/kie-conf.yaml b/examples/dev/kie-conf.yaml
index 703dbeb..11b9106 100644
--- a/examples/dev/kie-conf.yaml
+++ b/examples/dev/kie-conf.yaml
@@ -1,12 +1,11 @@
 db:
   # kind can be mongo, etcd, embedded_etcd
-  kind: etcd
+  kind: embedded_etcd
   # uri is the db endpoints list
   #   kind=mongo, then is the mongodb cluster's uri, e.g. mongodb://127.0.0.1:27017/kie
   #   kind=etcd, then is the  remote etcd server's advertise-client-urls, e.g. http://127.0.0.1:2379
   #   kind=embedded_etcd, then is the embedded etcd server's advertise-peer-urls, e.g. default=http://127.0.0.1:2380
   #uri: mongodb://kie:123@127.0.0.1:27017/kie
-  uri: http://127.0.0.1:2379
 #  poolSize: 10
 #  timeout: 5m
 #  sslEnabled: false
diff --git a/scripts/start.sh b/scripts/start.sh
index be4f0fd..2882f4e 100755
--- a/scripts/start.sh
+++ b/scripts/start.sh
@@ -14,68 +14,65 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
+set -e
 
 root_dir=/opt/servicecomb-kie
 net_name=$(ip -o -4 route show to default | awk '{print $5}')
 listen_addr=$(ifconfig ${net_name} | grep -E 'inet\W' | grep -o -E [0-9]+.[0-9]+.[0-9]+.[0-9]+ | head -n 1)
 if [ -z "${LOG_LEVEL}" ]; then
- export LOG_LEVEL="DEBUG"
+  export LOG_LEVEL="DEBUG"
 fi
 
-writeConfig(){
-echo "write template config..."
-cat <<EOM > ${root_dir}/conf/chassis.yaml
+writeConfig() {
+  echo "write template config..."
+  cat <<EOM >${root_dir}/conf/chassis.yaml
 servicecomb:
   registry:
     disabled: true
   protocols:
     rest:
       listenAddress: ${listen_addr}:30110
+  rateLimiting:
+    global: |
+      match: none
+      rate: 200
+      burst: 200
   handler:
     chain:
       Provider:
-        default: ratelimiter-provider,monitoring,jwt,track-handler
-servicecomb:
-  service:
-    quota:
-      plugin: build-in
+        default: access-log,monitoring,jwt,track-handler,traffic-marker,rate-limiter
 EOM
-cat <<EOM > ${root_dir}/conf/lager.yaml
-logLevel: ${LOG_LEVEL}
 
+  cat <<EOM >${root_dir}/conf/lager.yaml
+logWriters: file
+logLevel: ${LOG_LEVEL}
 logFile: log/chassis.log
-
-logFormatText: false
-
-rollingPolicy: size
-
-logRotateDate: 1
-
-logRotateSize: 10
-
-logBackupCount: 7
+logFormatText: true
+LogRotateCompress: true
+logRotateSize: 30
+logBackupCount: 20
+logRotateAge: 0
+accessLogFile: log/access.log
 EOM
 
-local uri="mongodb://${MONGODB_ADDR}/kie"
-if [ -n "${MONGODB_USER}" ]; then
-  uri="mongodb://${MONGODB_USER}:${MONGODB_PWD}@${MONGODB_ADDR}/kie"
-fi
+  db_type=${DB_KIND:-"mongo"}
+  uri=${DB_URI}
+  if [ -z "${uri}" ] && [ "${db_type}" == "mongo" ]; then
+    uri="mongodb://${MONGODB_ADDR}/kie"
+    if [ -n "${MONGODB_USER}" ]; then
+      uri="mongodb://${MONGODB_USER}:${MONGODB_PWD}@${MONGODB_ADDR}/kie"
+    fi
+  fi
 
-cat <<EOM > /etc/servicecomb-kie/kie-conf.yaml
+  cat <<EOM >${root_dir}/conf/kie-conf.yaml
 db:
+  kind: ${db_type}
   uri: ${uri}
-  type: mongodb
-  poolSize: 10
-  ssl: false
-  sslCA:
-  sslCert:
 EOM
 }
 
-
 echo "prepare config file...."
 writeConfig
 
 echo "start kie server"
-/opt/servicecomb-kie/kie --config /etc/servicecomb-kie/kie-conf.yaml
\ No newline at end of file
+/opt/servicecomb-kie/kie --config ${root_dir}/conf/kie-conf.yaml