vipshop / Saturn

The vip.com's distributed job scheduling platform.
Apache License 2.0
2.28k stars 701 forks source link

写Saturn Executor的Dockerfile时saturn与nacos的namespace系统变量有冲突 #645

Open jaychang9 opened 4 years ago

jaychang9 commented 4 years ago

FROM openjdk:8-jdk-alpine MAINTAINER jaychang jaychang1987@gmail.com

ARG SATURN_VERSION ARG FILE ARG APP_NAME ARG SATURN_EXECUTOR_DOWNLOAD_URL

ADD ${FILE} /${FILE}

RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories \ && apk update \ && apk add bash curl \ && rm -rf /var/cache/apk/ \ && wget ${SATURN_EXECUTOR_DOWNLOAD_URL} -O saturn-executor.zip \ && unzip ./saturn-executor.zip \ && rm -rf ./saturn-executor.zip \ && mv /saturn-executor- /saturn-executor \ && unzip /${FILE} \ && rm -rf /${FILE}

ENV TZ "Asia/Shanghai" ENV LIB_JARS=/saturn-executor/lib/*:$CLASSPATH ENV NAMESPACE=xxx.abc.om ENV VIP_SATURN_CONSOLE_URI=http://task.abc.com ENV NACOS_NAMESPACE="" ENV PINPOINT_VERSION=1.6.2 ENV PINPOINT_OPTS="-Dpinpoint.agentId=${APP_NAME} -Dpinpoint.applicationName=$APP_NAME -Dpinpoint.agentId.prefix=${APP_NAME}"

WORKDIR /saturn-executor

RUN ["chmod","+x","./bin/saturn-executor.sh"] CMD ["sh","-c","/saturn-executor/bin/saturn-executor.sh start -n $NAMESPACE -r foreground -env docker -javaagent:/pinpoint_data/pinpoint-agent-${PINPOINT_VERSION}/pinpoint-bootstrap-$PINPOINT_VERSION.jar $PINPOINT_OPTS -DVIP_SATURN_CONSOLE_URI=$VIP_SATURN_CONSOLE_URI -Dans.namespace=$NACOS_NAMESPACE"]

-Dans.namespace用于解决nacos与saturn对与namespace jvm系统变量的冲突问题

他们都会使用System.getProperty("namespace"),-Dans.namespace可以使得nacos client避免读取System.getProperty("namespace"),

从而避免读到xxx.abc.om,误把xxx.abc.om作为nacos server的命名空间

jaychang9 commented 4 years ago

这个不是bug,只是给大家一个提醒哈,方便有人遇到问题的时候,可以用google搜到。看到这个issue直接关闭就好

jaychang9 commented 4 years ago

如果是在idea里运行那么Command Line: saturn:run -Dnamespace=xxx.xyz.com -Dans.namespace=5a6e3d86-d130-4cf2-a365-a1af5b9fd7df 环境变量设为(Runner => Environment variables) VIP_SATURN_CONSOLE_URI=http://saturn-console-url