Commit da1ccae9 authored by nobodyiam's avatar nobodyiam

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

parent 16bf9e9d
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
<outputDirectory>config</outputDirectory> <outputDirectory>config</outputDirectory>
<excludes> <excludes>
<exclude>apollo-adminservice.conf</exclude> <exclude>apollo-adminservice.conf</exclude>
<exclude>application-github.properties</exclude>
</excludes> </excludes>
<lineEnding>unix</lineEnding> <lineEnding>unix</lineEnding>
</fileSet> </fileSet>
...@@ -34,6 +35,13 @@ ...@@ -34,6 +35,13 @@
</includes> </includes>
<lineEnding>unix</lineEnding> <lineEnding>unix</lineEnding>
</fileSet> </fileSet>
<fileSet>
<directory>target/classes</directory>
<outputDirectory>/config</outputDirectory>
<includes>
<include>application-github.properties</include>
</includes>
</fileSet>
<!--artifact --> <!--artifact -->
<fileSet> <fileSet>
<directory>target</directory> <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 @@ ...@@ -23,6 +23,7 @@
<outputDirectory>config</outputDirectory> <outputDirectory>config</outputDirectory>
<excludes> <excludes>
<exclude>apollo-configservice.conf</exclude> <exclude>apollo-configservice.conf</exclude>
<exclude>application-github.properties</exclude>
</excludes> </excludes>
<lineEnding>unix</lineEnding> <lineEnding>unix</lineEnding>
</fileSet> </fileSet>
...@@ -34,6 +35,13 @@ ...@@ -34,6 +35,13 @@
</includes> </includes>
<lineEnding>unix</lineEnding> <lineEnding>unix</lineEnding>
</fileSet> </fileSet>
<fileSet>
<directory>target/classes</directory>
<outputDirectory>/config</outputDirectory>
<includes>
<include>application-github.properties</include>
</includes>
</fileSet>
<!--artifact --> <!--artifact -->
<fileSet> <fileSet>
<directory>target</directory> <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 { ...@@ -27,6 +27,9 @@ public class SimpleApolloConfigDemo {
ConfigChangeListener changeListener = new ConfigChangeListener() { ConfigChangeListener changeListener = new ConfigChangeListener() {
@Override @Override
public void onChange(ConfigChangeEvent changeEvent) { public void onChange(ConfigChangeEvent changeEvent) {
if (!changeEvent.isChanged("someKey")) {
return;
}
logger.info("Changes for namespace {}", changeEvent.getNamespace()); logger.info("Changes for namespace {}", changeEvent.getNamespace());
for (String key : changeEvent.changedKeys()) { for (String key : changeEvent.changedKeys()) {
ConfigChange change = changeEvent.getChange(key); ConfigChange change = changeEvent.getChange(key);
......
...@@ -29,6 +29,7 @@ public class SpringBootApolloRefreshConfig { ...@@ -29,6 +29,7 @@ public class SpringBootApolloRefreshConfig {
public void onChange(ConfigChangeEvent changeEvent) { public void onChange(ConfigChangeEvent changeEvent) {
boolean redisCacheKeysChanged = false; boolean redisCacheKeysChanged = false;
for (String changedKey : changeEvent.changedKeys()) { for (String changedKey : changeEvent.changedKeys()) {
if (changeEvent.isChanged("someKey"))
if (changedKey.startsWith("redis.cache")) { if (changedKey.startsWith("redis.cache")) {
redisCacheKeysChanged = true; redisCacheKeysChanged = true;
break; break;
......
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
<fileSet> <fileSet>
<directory>src/main/config</directory> <directory>src/main/config</directory>
<outputDirectory>config</outputDirectory> <outputDirectory>config</outputDirectory>
<excludes> <includes>
<exclude>apollo-portal.conf</exclude> <include>app.properties</include>
</excludes> </includes>
<lineEnding>unix</lineEnding> <lineEnding>unix</lineEnding>
</fileSet> </fileSet>
<fileSet> <fileSet>
...@@ -34,6 +34,14 @@ ...@@ -34,6 +34,14 @@
</includes> </includes>
<lineEnding>unix</lineEnding> <lineEnding>unix</lineEnding>
</fileSet> </fileSet>
<fileSet>
<directory>target/classes</directory>
<outputDirectory>/config</outputDirectory>
<includes>
<include>application-github.properties</include>
<include>apollo-env.properties</include>
</includes>
</fileSet>
<!--artifact --> <!--artifact -->
<fileSet> <fileSet>
<directory>target</directory> <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 ...@@ -3,7 +3,7 @@ SERVICE_NAME=apollo-portal
## Adjust log dir if necessary ## Adjust log dir if necessary
LOG_DIR=/opt/logs/100003173 LOG_DIR=/opt/logs/100003173
## Adjust server port if necessary ## Adjust server port if necessary
SERVER_PORT=8080 SERVER_PORT=8070
## Adjust memory settings if necessary ## 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" #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 @@ ...@@ -526,6 +526,22 @@
<exclude>**/*.xml</exclude> <exclude>**/*.xml</exclude>
</excludes> </excludes>
</resource> </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> </resources>
</build> </build>
<profiles> <profiles>
......
#!/bin/sh #!/bin/sh
# apollo config db info # apollo config db info
apollo_config_db_url=jdbc:mysql://localhost:3306/ApolloConfigDB?characterEncoding=utf8 apollo_config_db_url=jdbc:mysql://fill-in-the-correct-server:3306/ApolloConfigDB?characterEncoding=utf8
apollo_config_db_username=root apollo_config_db_username=FillInCorrectUser
apollo_config_db_password= apollo_config_db_password=FillInCorrectPassword
# apollo portal db info # apollo portal db info
apollo_portal_db_url=jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8 apollo_portal_db_url=jdbc:mysql://fill-in-the-correct-server:3306/ApolloPortalDB?characterEncoding=utf8
apollo_portal_db_username=root apollo_portal_db_username=FillInCorrectUser
apollo_portal_db_password= apollo_portal_db_password=FillInCorrectPassword
# meta server url, different environments should have different meta server addresses # meta server url, different environments should have different meta server addresses
dev_meta=http://localhost:8080 dev_meta=http://fill-in-dev-meta-server:8080
fat_meta=http://someIp:8080 fat_meta=http://fill-in-fat-meta-server:8080
uat_meta=http://anotherIp:8080 uat_meta=http://fill-in-uat-meta-server:8080
pro_meta=http://yetAnotherIp: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" 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