diff --git a/tools/download_dependency.sh b/tools/download_dependency.sh index 4b13401cee03dd85b74de800c479d1981ee167c5..3b1b0fe2580744afafb5fddda4971173620ec1ab 100644 --- a/tools/download_dependency.sh +++ b/tools/download_dependency.sh @@ -131,7 +131,7 @@ function compile_frontend() { function compile_dashboard() { cd ${YR_DASHBOARD_SRC_DIR} - bash build/build.sh + bash build.sh } function compile_all(){ diff --git a/yuanrong/build/build.sh b/yuanrong/build.sh similarity index 68% rename from yuanrong/build/build.sh rename to yuanrong/build.sh index 850ed7544bba1cb8775323cee27289299a266d07..c81261ee12fbcc9693981423ccdd64ea0dce7f99 100644 --- a/yuanrong/build/build.sh +++ b/yuanrong/build.sh @@ -15,14 +15,37 @@ set -e -BASE_DIR=$(cd "$(dirname "$0")"; pwd) -PROJECT_DIR=$(cd "$(dirname "$0")"/..; pwd) +readonly USAGE=" +Usage: bash build.sh [-h] [-v ] + +Options: + -v, --version show version. + -h show usage. +" + +PROJECT_DIR=$(cd "$(dirname "$0")"; pwd) OUTPUT_DIR="${PROJECT_DIR}/output" RUNTIME_OUTPUT_DIR="${PROJECT_DIR}/../output" POSIX_DIR="${PROJECT_DIR}/proto/posix" BUILD_TAGS="" +VERSION="" FLAGS='-extldflags "-fPIC -fstack-protector-strong -Wl,-z,now,-z,relro,-z,noexecstack,-s -Wall -Werror"' +while [[ $# -gt 0 ]]; do + case $1 in + -v|--version) + if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then + VERSION="$2" + shift 2 + fi + ;; + -h|--help) + echo -e "${USAGE}" + exit 0 + ;; + esac +done + go install google.golang.org/protobuf/cmd/protoc-gen-go@latest go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest @@ -41,29 +64,35 @@ echo "start to compile dashboard -s ${SCC_BUILD_ENABLED}" mkdir -p "${OUTPUT_DIR}/bin/" rm -rf "${OUTPUT_DIR}/bin/dashboard" -CC='gcc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -O2' go build -tags="${BUILD_TAGS}" -buildmode=pie -ldflags "${FLAGS}" -o \ +DASHBOARD_FLAGS="${FLAGS} -X 'yuanrong/pkg/dashboard/flags.version=${VERSION}'" +CC='gcc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -O2' go build -tags="${BUILD_TAGS}" -buildmode=pie -ldflags "${DASHBOARD_FLAGS}" -o \ "${OUTPUT_DIR}"/bin/dashboard "${PROJECT_DIR}"/cmd/dashboard/main.go mkdir -p "${OUTPUT_DIR}/config/" rm -rf "${OUTPUT_DIR}/config/dashboard*" -cp -ar "${BASE_DIR}/dashboard/config/" "${OUTPUT_DIR}/" +cp -ar "${PROJECT_DIR}/build/dashboard/config/" "${OUTPUT_DIR}/" npm config set strict-ssl false echo "start to compile dashboard client" mkdir -p "${OUTPUT_DIR}/bin/" rm -rf "${OUTPUT_DIR}/bin/client" cd "${PROJECT_DIR}/pkg/dashboard/client" +CLIENT_CONFIG_DIR="${PROJECT_DIR}/pkg/dashboard/client/src/config" +rm -f "${CLIENT_CONFIG_DIR}/config.json" +cp "${CLIENT_CONFIG_DIR}/config.json.bak" "${CLIENT_CONFIG_DIR}/config.json" +sed -i "s#{version}#${VERSION}#g" "${CLIENT_CONFIG_DIR}/config.json" npm install || die "dashboard client install failed" npm run build || die "dashboard client build failed" mkdir -p "${OUTPUT_DIR}/bin/client" cp -ar ./dist "${OUTPUT_DIR}/bin/client/" -cd "${BASE_DIR}" +cd "${PROJECT_DIR}" echo "start to compile collector" mkdir -p "${OUTPUT_DIR}/bin/" rm -rf "${OUTPUT_DIR}/bin/collector" echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH -CC='gcc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -O2' go build -tags="${BUILD_TAGS}" -buildmode=pie -ldflags "${FLAGS}" -o \ +COLLECTOR_FLAGS="${FLAGS} -X 'yuanrong/pkg/collector/common.version=${VERSION}'" +CC='gcc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -O2' go build -tags="${BUILD_TAGS}" -buildmode=pie -ldflags "${COLLECTOR_FLAGS}" -o \ "${OUTPUT_DIR}"/bin/collector "${PROJECT_DIR}"/cmd/collector/main.go cd "${OUTPUT_DIR}" @@ -71,4 +100,4 @@ tar -czvf yr-dashboard-v0.0.1.tar.gz ./* mkdir -p "${RUNTIME_OUTPUT_DIR}" rm -rf "${RUNTIME_OUTPUT_DIR}/yr-dashboard-v0.0.1.tar.gz" cp yr-dashboard-v0.0.1.tar.gz "${RUNTIME_OUTPUT_DIR}" -cd "${BASE_DIR}" \ No newline at end of file +cd "${PROJECT_DIR}" \ No newline at end of file diff --git a/yuanrong/pkg/collector/common/flags.go b/yuanrong/pkg/collector/common/flags.go index 27fdc97f8b2c2d7e2ddf3921f465b29aa020f82f..11a9a1947da81e7b1ce973f7061d8117f3c750c2 100644 --- a/yuanrong/pkg/collector/common/flags.go +++ b/yuanrong/pkg/collector/common/flags.go @@ -44,6 +44,8 @@ type CollectorConfig struct { } var ( + version string + showVersion bool // CollectorConfigs - CollectorConfigs CollectorConfig ) @@ -69,6 +71,10 @@ func InitCmd() { if err := rootCmd.Execute(); err != nil { log.GetLogger().Fatal(err.Error()) } + if showVersion { + fmt.Println(version) + os.Exit(0) + } if err := validateCmdArgs(); err != nil { log.GetLogger().Fatal(err.Error()) } @@ -76,6 +82,7 @@ func InitCmd() { } func registerCmdArgs(rootCmd *cobra.Command) { + rootCmd.Flags().BoolVarP(&showVersion, "version", "v", false, "show version") rootCmd.Flags().StringVarP(&CollectorConfigs.CollectorID, "collect_id", "", "", "the identifier; of length less than 256") rootCmd.Flags().StringVarP(&CollectorConfigs.IP, "ip", "", "", "the ip of collector for manager to access") diff --git a/yuanrong/pkg/common/faas_common/localauth/authcheck.go b/yuanrong/pkg/common/faas_common/localauth/authcheck.go index ebfbc936ad4ce078cb15dcb213db62433190fe23..676d46d3dfa7b38f9f65db6d6cb5fd50175a20ef 100644 --- a/yuanrong/pkg/common/faas_common/localauth/authcheck.go +++ b/yuanrong/pkg/common/faas_common/localauth/authcheck.go @@ -307,7 +307,6 @@ func getTimestampDiffLimit() float64 { } else { tsDiffLimit = float64(defaultTimestampDiffLimit) } - log.GetLogger().Infof("current timestampDiffLimit is %f", tsDiffLimit) return tsDiffLimit } diff --git a/yuanrong/pkg/dashboard/client/src/config/config.json.bak b/yuanrong/pkg/dashboard/client/src/config/config.json.bak new file mode 100644 index 0000000000000000000000000000000000000000..706ec518adf61b94d17c0cce8c95eb57df9129eb --- /dev/null +++ b/yuanrong/pkg/dashboard/client/src/config/config.json.bak @@ -0,0 +1,3 @@ +{ + "version": "{version}" +} \ No newline at end of file diff --git a/yuanrong/pkg/dashboard/client/src/pages/layout.vue b/yuanrong/pkg/dashboard/client/src/pages/layout.vue index 6dd53136d8e9c000c7fb0402dac6fadfe73a5bc7..ef7864ae9ddd0732af551300009e217dd8637bc3 100644 --- a/yuanrong/pkg/dashboard/client/src/pages/layout.vue +++ b/yuanrong/pkg/dashboard/client/src/pages/layout.vue @@ -20,6 +20,9 @@ + @@ -29,6 +32,7 @@ import { ref } from 'vue'; import { TinyNavMenu } from '@opentiny/vue'; import Logo from '@/../public/logo.png'; +import config from '@/config/config.json'; const menuData = ref([ { @@ -76,6 +80,9 @@ const TinyIconTotal = Logo; height: 30px; margin-top: 8px; } - - +.version { + font-weight: normal; + font-size: 15px; +} + diff --git a/yuanrong/pkg/dashboard/flags/flags.go b/yuanrong/pkg/dashboard/flags/flags.go index 11b59c202d55a8cb3b453512e5386b1e931f5ec6..8afaf4e00934a3f89a0e201d4bf9ad5f043c5539 100644 --- a/yuanrong/pkg/dashboard/flags/flags.go +++ b/yuanrong/pkg/dashboard/flags/flags.go @@ -22,6 +22,7 @@ import ( "encoding/json" "errors" "fmt" + "os" "strings" "time" @@ -66,6 +67,8 @@ const ( ) var ( + version string + showVersion bool // DashboardConfig is the global config struct DashboardConfig dashboardConfig @@ -169,6 +172,11 @@ func RegisterSelfToEtcd(stopCh <-chan struct{}) error { func initWithConfigFiles(cCmd *cobra.Command) { cmdErr(cCmd.Execute()) + if showVersion { + fmt.Println(version) + os.Exit(0) + } + if err := initLog(); err != nil { log.GetLogger().Errorf("failed to init dashboard log, err: %s", err.Error()) } @@ -196,6 +204,7 @@ func cobraCmd() *cobra.Command { } // if config path, use config path + cCmd.Flags().BoolVarP(&showVersion, "version", "v", false, "show version") cCmd.Flags().StringVarP(&dashboardConfigPath, "config_path", "", "", "config file path") cCmd.Flags().StringVarP(&dashboardLogConfigPath, "log_config_path", "", "", "log config file path")