Commit da1ccae9 authored by nobodyiam's avatar nobodyiam

externalize application-github.properties and apollo-env.properties

parent 16bf9e9d
......@@ -23,6 +23,7 @@
<outputDirectory>config</outputDirectory>
<excludes>
<exclude>apollo-adminservice.conf</exclude>
<exclude>application-github.properties</exclude>
</excludes>
<lineEnding>unix</lineEnding>
</fileSet>
......@@ -34,6 +35,13 @@
</includes>
<lineEnding>unix</lineEnding>
</fileSet>
<fileSet>
<directory>target/classes</directory>
<outputDirectory>/config</outputDirectory>
<includes>
<include>application-github.properties</include>
</includes>
</fileSet>
<!--artifact -->
<fileSet>
<directory>target</directory>
......
# DataSource
spring.datasource.url = ${spring_datasource_url}
spring.datasource.username = ${spring_datasource_username}
spring.datasource.password = ${spring_datasource_password}
......@@ -23,6 +23,7 @@
<outputDirectory>config</outputDirectory>
<excludes>
<exclude>apollo-configservice.conf</exclude>
<exclude>application-github.properties</exclude>
</excludes>
<lineEnding>unix</lineEnding>
</fileSet>
......@@ -34,6 +35,13 @@
</includes>
<lineEnding>unix</lineEnding>
</fileSet>
<fileSet>
<directory>target/classes</directory>
<outputDirectory>/config</outputDirectory>
<includes>
<include>application-github.properties</include>
</includes>
</fileSet>
<!--artifact -->
<fileSet>
<directory>target</directory>
......
# DataSource
spring.datasource.url = ${spring_datasource_url}
spring.datasource.username = ${spring_datasource_username}
spring.datasource.password = ${spring_datasource_password}
......@@ -27,6 +27,9 @@ public class SimpleApolloConfigDemo {
ConfigChangeListener changeListener = new ConfigChangeListener() {
@Override
public void onChange(ConfigChangeEvent changeEvent) {
if (!changeEvent.isChanged("someKey")) {
return;
}
logger.info("Changes for namespace {}", changeEvent.getNamespace());
for (String key : changeEvent.changedKeys()) {
ConfigChange change = changeEvent.getChange(key);
......
......@@ -29,6 +29,7 @@ public class SpringBootApolloRefreshConfig {
public void onChange(ConfigChangeEvent changeEvent) {
boolean redisCacheKeysChanged = false;
for (String changedKey : changeEvent.changedKeys()) {
if (changeEvent.isChanged("someKey"))
if (changedKey.startsWith("redis.cache")) {
redisCacheKeysChanged = true;
break;
......
......@@ -21,9 +21,9 @@
<fileSet>
<directory>src/main/config</directory>
<outputDirectory>config</outputDirectory>
<excludes>
<exclude>apollo-portal.conf</exclude>
</excludes>
<includes>
<include>app.properties</include>
</includes>
<lineEnding>unix</lineEnding>
</fileSet>
<fileSet>
......@@ -34,6 +34,14 @@
</includes>
<lineEnding>unix</lineEnding>
</fileSet>
<fileSet>
<directory>target/classes</directory>
<outputDirectory>/config</outputDirectory>
<includes>
<include>application-github.properties</include>
<include>apollo-env.properties</include>
</includes>
</fileSet>
<!--artifact -->
<fileSet>
<directory>target</directory>
......
local.meta=http://localhost:8080
dev.meta=${dev_meta}
fat.meta=${fat_meta}
uat.meta=${uat_meta}
lpt.meta=${lpt_meta}
pro.meta=${pro_meta}
# DataSource
spring.datasource.url = ${spring_datasource_url}
spring.datasource.username = ${spring_datasource_username}
spring.datasource.password = ${spring_datasource_password}
......@@ -3,7 +3,7 @@ SERVICE_NAME=apollo-portal
## Adjust log dir if necessary
LOG_DIR=/opt/logs/100003173
## Adjust server port if necessary
SERVER_PORT=8080
SERVER_PORT=8070
## Adjust memory settings if necessary
#export JAVA_OPTS="-Xms2560m -Xmx2560m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=1536m -XX:MaxNewSize=1536m -XX:SurvivorRatio=8"
......
......@@ -526,6 +526,22 @@
<exclude>**/*.xml</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/config</directory>
<filtering>true</filtering>
<includes>
<include>application-github.properties</include>
<include>apollo-env.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/config</directory>
<filtering>false</filtering>
<excludes>
<exclude>application-github.properties</exclude>
<exclude>apollo-env.properties</exclude>
</excludes>
</resource>
</resources>
</build>
<profiles>
......
#!/bin/sh
# apollo config db info
apollo_config_db_url=jdbc:mysql://localhost:3306/ApolloConfigDB?characterEncoding=utf8
apollo_config_db_username=root
apollo_config_db_password=
apollo_config_db_url=jdbc:mysql://fill-in-the-correct-server:3306/ApolloConfigDB?characterEncoding=utf8
apollo_config_db_username=FillInCorrectUser
apollo_config_db_password=FillInCorrectPassword
# apollo portal db info
apollo_portal_db_url=jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8
apollo_portal_db_username=root
apollo_portal_db_password=
apollo_portal_db_url=jdbc:mysql://fill-in-the-correct-server:3306/ApolloPortalDB?characterEncoding=utf8
apollo_portal_db_username=FillInCorrectUser
apollo_portal_db_password=FillInCorrectPassword
# meta server url, different environments should have different meta server addresses
dev_meta=http://localhost:8080
fat_meta=http://someIp:8080
uat_meta=http://anotherIp:8080
pro_meta=http://yetAnotherIp:8080
dev_meta=http://fill-in-dev-meta-server:8080
fat_meta=http://fill-in-fat-meta-server:8080
uat_meta=http://fill-in-uat-meta-server:8080
pro_meta=http://fill-in-pro-meta-server:8080
META_SERVERS_OPTS="-Ddev_meta=$dev_meta -Dfat_meta=$fat_meta -Duat_meta=$uat_meta -Dpro_meta=$pro_meta"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment