Skip to content

Commit 536cfcc

Browse files
committed
env key
1 parent d02246e commit 536cfcc

File tree

20 files changed

+75
-48
lines changed

20 files changed

+75
-48
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ image_push:
1010
app_run:
1111
docker run -e REGISTRY_APP_NAME=integration -d --net=host --name=sofa-registry --rm -v /Users/dzdx/Desktop/registry-all/conf/application.properties:/registry-distribution/registry-all/conf/application.properties dzdx/sofa-registry-test:latest
1212
mysql_run:
13-
docker run --rm -e MARIADB_ROOT_PASSWORD=root -p 3306:3306 --name=mysql -v /Users/dzdx/Desktop/registry-all:/registry-distribution/registry-all -d --net=host mariadb:10.7
13+
docker run --rm -e MARIADB_ROOT_PASSWORD=root -p 3306:3306 --name=mysql -v /Users/dzdx/Desktop/registry-all:/registry-distribution/registry-all -d mariadb:10.7

docker/kube/integration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ data:
4747
nodes.localRegion=DEFAULT_ZONE
4848
jdbc.url=jdbc:mysql://mysql.default.svc.cluster.local:3306/registrymetadb
4949
jdbc.username=root
50-
jdbc.password=
50+
jdbc.password=root
5151
---
5252
apiVersion: v1
5353
kind: Secret

server/common/util/src/main/java/com/alipay/sofa/registry/util/SystemUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,23 @@ private SystemUtils() {}
2424
public static int getSystemInteger(String name, int def) {
2525
String v = System.getProperty(name);
2626
if (v == null) {
27-
v = System.getenv(name);
27+
v = System.getenv(convertEnvKey(name));
2828
}
2929
return v == null ? def : Integer.parseInt(v);
3030
}
3131

3232
public static long getSystemLong(String name, long def) {
3333
String v = System.getProperty(name);
3434
if (v == null) {
35-
v = System.getenv(name);
35+
v = System.getenv(convertEnvKey(name));
3636
}
3737
return v == null ? def : Long.parseLong(v);
3838
}
3939

4040
public static String getSystem(String name, String def) {
4141
String v = System.getProperty(name);
4242
if (v == null) {
43-
v = System.getenv(name);
43+
v = System.getenv(convertEnvKey(name));
4444
}
4545
return v == null ? def : v;
4646
}
@@ -49,7 +49,7 @@ public static String getSystem(String name) {
4949
return getSystem(name, null);
5050
}
5151

52-
public static String convertEnvKey(String key) {
52+
private static String convertEnvKey(String key) {
5353
return StringUtils.replace(key, ".", "_").toUpperCase();
5454
}
5555
}

server/distribution/all/bin/base/start_base.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ if [[ -z "$REGISTRY_APP_NAME" ]]; then
99
fi
1010
BASE_DIR=`cd $(dirname $0)/../..; pwd`
1111
APP_JAR="${BASE_DIR}/registry-${REGISTRY_APP_NAME}.jar"
12+
# set user.home
13+
JAVA_OPTS="$JAVA_OPTS -Duser.home=${BASE_DIR}"
14+
1215
if [[ -z "$SPRING_CONFIG_LOCATION" ]]; then
13-
SPRING_CONFIG_LOCATION=${BASE_DIR}/conf/application.properties
16+
SPRING_CONFIG_LOCATION=${BASE_DIR}/conf/
17+
fi
18+
JAVA_OPTS="$JAVA_OPTS -Dspring.config.additional-location=${SPRING_CONFIG_LOCATION}"
19+
20+
if [[ -n "$SPRING_PROFILES_ACTIVE" ]]; then
21+
JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=${SPRING_PROFILES_ACTIVE}"
1422
fi
1523

16-
# set user.home
17-
JAVA_OPTS="$JAVA_OPTS -Duser.home=${BASE_DIR} -Dspring.config.location=${SPRING_CONFIG_LOCATION}"
1824

1925
# springboot conf
2026
SPRINGBOOT_OPTS="${SPRINGBOOT_OPTS} -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
22

33
BASE_DIR=`cd $(dirname $0)/../..; pwd`
4+
export SPRING_PROFILES_ACTIVE="prod"
45
REGISTRY_APP_NAME=integration exec ${BASE_DIR}/bin/base/start_base.sh
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22

33
BASE_DIR=`cd $(dirname $0)/../..; pwd`
4-
export SPRING_CONFIG_LOCATION=${BASE_DIR}/conf/application-h2.properties
4+
export SPRING_PROFILES_ACTIVE="dev"
55
REGISTRY_APP_NAME=integration exec ${BASE_DIR}/bin/base/start_base.sh

server/distribution/all/conf/application-h2.properties renamed to server/distribution/all/conf/application-dev.properties

File renamed without changes.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
nodes.localDataCenter=DefaultDataCenter
22
nodes.localRegion=DEFAULT_ZONE
33
## connect db
4+
jdbc.driverClassName=com.mysql.jdbc.Driver
45
jdbc.url=jdbc:mysql://127.0.0.1:3306/registrymetadb
56
jdbc.username=root
6-
jdbc.password=
7+
jdbc.password=root

server/server/data/src/main/java/com/alipay/sofa/registry/server/data/bootstrap/DataServerBootstrap.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ private void gracefulShutdown() {
321321
}
322322
return true;
323323
});
324+
LOGGER.info("add data self to blacklist successfully");
324325
} catch (Throwable e) {
325326
LOGGER.error("add blacklist failed:", e);
326327
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
nodes.localDataCenter=DefaultDataCenter
22
nodes.localRegion=DEFAULT_ZONE
33
## connect db
4-
jdbc.url=jdbc:mysql://127.0.0.1:2883/registrymetadb?useUnicode=true&characterEncoding=utf8
5-
jdbc.username=username
6-
jdbc.password=password
4+
jdbc.driverClassName=com.mysql.jdbc.Driver
5+
jdbc.url=jdbc:mysql://127.0.0.1:3306/registrymetadb?useUnicode=true&characterEncoding=utf8
6+
jdbc.username=root
7+
jdbc.password=root
8+
data.server.gracefulShutdown=true

0 commit comments

Comments
 (0)