Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
F
feo-jobs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
探普后端
feo-jobs
Commits
49982d38
Commit
49982d38
authored
Jun 15, 2021
by
钱坤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加apollo刷新
parent
cbe2cfc7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
129 additions
and
2 deletions
+129
-2
ApolloRefresherConfiguration.java
...tanpu/feo/feojob/config/ApolloRefresherConfiguration.java
+69
-0
application-prod.yml
src/main/resources/application-prod.yml
+60
-2
No files found.
src/main/java/com/tanpu/feo/feojob/config/ApolloRefresherConfiguration.java
0 → 100644
View file @
49982d38
package
com
.
tanpu
.
feo
.
feojob
.
config
;
import
com.ctrip.framework.apollo.Config
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfig
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener
;
import
com.ctrip.framework.apollo.spring.boot.ApolloAutoConfiguration
;
import
com.ctrip.framework.apollo.spring.config.PropertySourcesConstants
;
import
com.tanpu.common.constant.CommonConstant
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeansException
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.cloud.context.environment.EnvironmentChangeEvent
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
java.util.Iterator
;
import
java.util.Set
;
/*动态刷新日志参数配置和tanpu.开头的配置*/
@Component
@Slf4j
@ConditionalOnProperty
(
PropertySourcesConstants
.
APOLLO_BOOTSTRAP_ENABLED
)
@AutoConfigureAfter
(
ApolloAutoConfiguration
.
class
)
public
class
ApolloRefresherConfiguration
implements
ApplicationContextAware
{
private
ApplicationContext
applicationContext
;
@ApolloConfig
private
Config
config
;
@PostConstruct
private
void
initialize
()
{
log
.
info
(
"初始化配置变更监听"
);
refresh
(
config
.
getPropertyNames
());
}
// 刷新参数(刷新"common"和"application"空间中,"logging.level."或"tanpu."开头的配置 )
@ApolloConfigChangeListener
(
value
=
{
CommonConstant
.
APOLLO_COMMON_APP_ID
,
"application"
},
interestedKeyPrefixes
=
{
"logging.level."
,
"tanpu."
})
public
void
onChangeLogLevel
(
ConfigChangeEvent
changeEvent
)
{
log
.
info
(
"Refreshing logging levels and tanpu."
);
Iterator
<
String
>
iterator
=
changeEvent
.
changedKeys
().
iterator
();
while
(
iterator
.
hasNext
())
{
log
.
info
(
"refresh key:{}"
,
iterator
.
next
());
}
this
.
applicationContext
.
publishEvent
(
new
EnvironmentChangeEvent
(
changeEvent
.
changedKeys
()));
log
.
info
(
"Logging levels and tanpu. refreshed"
);
}
/** 刷新参数配置 */
private
void
refresh
(
Set
<
String
>
changedKeys
)
{
log
.
info
(
"Refreshing logging.level and tanpu. properties"
);
Iterator
<
String
>
iterator
=
changedKeys
.
iterator
();
while
(
iterator
.
hasNext
())
{
log
.
info
(
"refresh key:{}"
,
iterator
.
next
());
}
this
.
applicationContext
.
publishEvent
(
new
EnvironmentChangeEvent
(
changedKeys
));
log
.
info
(
"logging.level properties and tanpu. refreshed"
);
}
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
this
.
applicationContext
=
applicationContext
;
}
}
src/main/resources/application-prod.yml
View file @
49982d38
apollo
:
server
:
meta
:
http://prod-feo-apollo.tamp-innner.com:8080
port
:
8091
servlet
:
context-path
:
/feo-jobs
spring
:
application
:
name
:
feo-jobs
datasource
:
user
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
initialize
:
false
#指定初始化数据源,是否用data.sql来初始化,默认: true
jdbc-url
:
jdbc:mysql://rm-uf6ol58l59c62fyr7.mysql.rds.aliyuncs.com:3306/tamp_feo_user?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL
username
:
tamp_feo_wr
password
:
FpNhH22GbD1FwTBApnN
diagnose
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
initialize
:
false
#指定初始化数据源,是否用data.sql来初始化,默认: true
jdbc-url
:
jdbc:mysql://rm-uf6ol58l59c62fyr7.mysql.rds.aliyuncs.com:3306/tamp_feo_diagnose_app?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL
username
:
tamp_feo_wr
password
:
FpNhH22GbD1FwTBApnN
jyzyuser
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
initialize
:
false
#指定初始化数据源,是否用data.sql来初始化,默认: true
jdbc-url
:
jdbc:mysql://pc-uf666afrpfg8yj768.rwlb.rds.aliyuncs.com:3306/fatools?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL
username
:
jyzy_read_rd
password
:
iBJoUkaGIYOpTxw2
zipkin
:
enabled
:
false
# 监控关掉
cloud
:
consul
:
host
:
prod-feo-consul.tamp-innner.com
port
:
8500
discovery
:
service-name
:
${spring.application.name}
prefer-ip-address
:
true
health-check-interval
:
3s
tags
:
PRO
default-query-tag
:
PRO
enabled
:
false
enabled
:
false
spring.jackson
:
time-zone
:
GMT+8
date-format
:
yyyy-MM-dd HH:mm:ss
user
:
wxDefaultImg
:
https://tamp-prod-feo-biz.oss-cn-shanghai.aliyuncs.com/common/fatoolsHeadImgMp-1228.png
#微信
wx
:
#用户小程序二维码生成接口 wx12c5764ee9aeab05 为小程序appid
xcxqrcode
:
https://feotamper.tanpuyun.com/wxmini/wx/user/wx30500d60f0b13671/getBallCode
logging
:
level
:
com
:
tanpu
:
debug
apollo
:
bootstrap
:
enabled
:
false
# 启用apollo配置中心
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment