首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Spring (ConfigServer)一直在重新启动

Spring (ConfigServer)一直在重新启动
EN

Stack Overflow用户
提问于 2015-04-08 11:41:22
回答 3查看 2.4K关注 0票数 5

我们在nginx代理后面运行了一个非常简单的Service (@EnableConfigServer)。

该服务基本上正常工作,但它一直在重新启动(上下文被关闭并持续启动)。

参见此处的日志文件:http://pastebin.com/GErCF5x6

设置基本上只是一个Java和两个信任(bootstrap.properties和application.properties)。

代码语言:javascript
运行
复制
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.cloud.config.server.EnableConfigServer;
import org.springframework.context.annotation.Configuration;

/**
 * Main Application, which starts the Spring Boot context
 */
@Configuration
@EnableAutoConfiguration
@EnableConfigServer
public class Application {

    @SuppressWarnings("PMD.SignatureDeclareThrowsException")
    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class, args);
    }
}

bootstrap.properties

代码语言:javascript
运行
复制
spring.application.name = configserver
spring.cloud.config.enabled = false
encrypt.failOnError= false
encrypt.key= secret

application.properties

代码语言:javascript
运行
复制
# HTTP Configuration
server.port = 8888

# Management Configuration
management.context-path=/manage

# SSH Based Git-Repository
spring.cloud.config.server.git.uri=git@bitbucket.org:xyz.git
spring.cloud.config.server.git.basedir = cache/config

security.user.name=ads
security.user.password={cipher}secret2
security.basic.realm=Config Server

日志-文件

代码语言:javascript
运行
复制
11:13:47.105 [qtp1131266554-101] INFO  o.s.boot.SpringApplication - Started application in 0.176 seconds (JVM running for 245.66)
11:13:47.105 [qtp1131266554-101] INFO  o.s.c.a.AnnotationConfigApplicationContext - Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@7709b120: startup date [Wed Apr 08 11:13:47 UTC 2015]; root of context hierarchy
11:13:47.690 [qtp1131266554-51] INFO  o.s.b.a.audit.listener.AuditListener - AuditEvent [timestamp=Wed Apr 08 11:13:47 UTC 2015, principal=ads, type=AUTHENTICATION_SUCCESS, data={details=org.springframework.security.web.authentication.WebAuthenticationDetails@ffffe21a: RemoteIpAddress: 10.10.100.207; SessionId: null}]
11:13:48.324 [qtp1131266554-19] INFO  o.s.boot.SpringApplication - Starting application on api01.prd.rbx.xxxx.com with PID 24204 (started by ads in /home/ads/config-server)
11:13:48.328 [qtp1131266554-19] INFO  o.s.c.a.AnnotationConfigApplicationContext - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@473cffd3: startup date [Wed Apr 08 11:13:48 UTC 2015]; root of context hierarchy
11:13:48.332 [qtp1131266554-19] INFO  o.s.boot.SpringApplication - Started application in 0.092 seconds (JVM running for 246.887)
11:13:48.332 [qtp1131266554-19] INFO  o.s.c.a.AnnotationConfigApplicationContext - Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@473cffd3: startup date [Wed Apr 08 11:13:48 UTC 2015]; root of context hierarchy
11:13:48.612 [qtp1131266554-55] INFO  o.s.b.a.audit.listener.AuditListener - AuditEvent [timestamp=Wed Apr 08 11:13:48 UTC 2015, principal=ads, type=AUTHENTICATION_SUCCESS, data={details=org.springframework.security.web.authentication.WebAuthenticationDetails@ffffe21a: RemoteIpAddress: 10.10.100.207; SessionId: null}]
11:13:50.601 [qtp1131266554-77] INFO  o.s.boot.SpringApplication - Starting application on api01.prd.rbx.xxxx.com with PID 24204 (started by ads in /home/ads/config-server)
11:13:50.604 [qtp1131266554-77] INFO  o.s.c.a.AnnotationConfigApplicationContext - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@44330486: startup date [Wed Apr 08 11:13:50 UTC 2015]; root of context hierarchy
11:13:50.607 [qtp1131266554-77] INFO  o.s.boot.SpringApplication - Started application in 0.088 seconds (JVM running for 249.162)
11:13:50.607 [qtp1131266554-77] INFO  o.s.c.a.AnnotationConfigApplicationContext - Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@44330486: startup date [Wed Apr 08 11:13:50 UTC 2015]; root of context hierarchy
11:13:51.831 [qtp1131266554-55] INFO  o.s.boot.SpringApplication - Starting application on api01.prd.rbx.xxxx.com with PID 24204 (started by ads in /home/ads/config-server)
11:13:51.834 [qtp1131266554-55] INFO  o.s.c.a.AnnotationConfigApplicationContext - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@1843040d: startup date [Wed Apr 08 11:13:51 UTC 2015]; root of context hierarchy
11:13:51.840 [qtp1131266554-55] INFO  o.s.boot.SpringApplication - Started application in 0.094 seconds (JVM running for 250.395)

知道吗,怎么解决这个问题?

最好的,弗里茨

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2015-04-08 16:26:19

这很正常。启动和停止的不是应用程序,而是用于为远程客户端创建配置资源的迷你上下文。完全无害。

票数 5
EN

Stack Overflow用户

发布于 2015-04-08 21:23:04

我发现了我在这里面临的问题。基本上,我们有两个运行在AWS上的远程服务和一个配置好的Load,它连续地检查/health端点。通过调用此方法,ConfigServerClient总是调用我们的ConfigServer。

我不明白为什么有一个HealthIndicator用于ConfigServer,是否有一种方法来禁用这个HealthIndicator,因为对这个端点的每个请求都会一次又一次地查询我们的配置服务器。另一个缺点是,/health请求不再以尽可能快的速度响应,这将导致负载均衡器中的超时(默认为2s)。

票数 1
EN

Stack Overflow用户

发布于 2015-04-08 16:26:17

因此,配置服务器不会重新启动。它使用一个新的上下文,并将它从git抓取的文件加载到一个新的上下文中,并格式化要发送回客户端的值。下面是来自我的配置服务器的一个客户端连接的日志。日志看起来很混乱,好像它正在重新启动。

代码语言:javascript
运行
复制
2015-04-08 12:22:52.206  INFO 85076 --- [nio-8888-exec-1] o.s.b.a.audit.listener.AuditListener     : AuditEvent [timestamp=Wed Apr 08 12:22:52 EDT 2015, principal=user, type=AUTHENTICATION_SUCCESS, data={details=org.springframework.security.web.authentication.WebAuthenticationDetails@957e: RemoteIpAddress: 127.0.0.1; SessionId: null}]
2015-04-08 12:22:52.944  INFO 85076 --- [nio-8888-exec-2] o.s.b.a.audit.listener.AuditListener     : AuditEvent [timestamp=Wed Apr 08 12:22:52 EDT 2015, principal=user, type=AUTHENTICATION_SUCCESS, data={details=org.springframework.security.web.authentication.WebAuthenticationDetails@957e: RemoteIpAddress: 127.0.0.1; SessionId: null}]
2015-04-08 12:22:53.490  INFO 85076 --- [nio-8888-exec-1] o.s.boot.SpringApplication               : Starting application on sgibb-mbp.local with PID 85076 (started by sgibb in /Users/sgibb/workspace/spring/spring-cloud-samples/configserver)
2015-04-08 12:22:53.494  INFO 85076 --- [nio-8888-exec-1] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@571e4b84: startup date [Wed Apr 08 12:22:53 EDT 2015]; root of context hierarchy
2015-04-08 12:22:53.497  INFO 85076 --- [nio-8888-exec-1] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2015-04-08 12:22:53.498  INFO 85076 --- [nio-8888-exec-1] o.s.boot.SpringApplication               : Started application in 0.151 seconds (JVM running for 23.747)
2015-04-08 12:22:53.499  INFO 85076 --- [nio-8888-exec-1] o.s.c.c.s.NativeEnvironmentRepository    : Adding property source: file:/Users/sgibb/workspace/spring/spring-cloud-samples/configserver/target/config/foo.properties
2015-04-08 12:22:53.500  INFO 85076 --- [nio-8888-exec-1] o.s.c.c.s.NativeEnvironmentRepository    : Adding property source: file:/Users/sgibb/workspace/spring/spring-cloud-samples/configserver/target/config/application.yml
2015-04-08 12:22:53.500  INFO 85076 --- [nio-8888-exec-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@571e4b84: startup date [Wed Apr 08 12:22:53 EDT 2015]; root of context hierarchy
2015-04-08 12:22:54.090  INFO 85076 --- [nio-8888-exec-2] o.s.boot.SpringApplication               : Starting application on sgibb-mbp.local with PID 85076 (started by sgibb in /Users/sgibb/workspace/spring/spring-cloud-samples/configserver)
2015-04-08 12:22:54.096  INFO 85076 --- [nio-8888-exec-2] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@416d044c: startup date [Wed Apr 08 12:22:54 EDT 2015]; root of context hierarchy
2015-04-08 12:22:54.098  INFO 85076 --- [nio-8888-exec-2] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2015-04-08 12:22:54.099  INFO 85076 --- [nio-8888-exec-2] o.s.boot.SpringApplication               : Started application in 0.433 seconds (JVM running for 24.348)
2015-04-08 12:22:54.099  INFO 85076 --- [nio-8888-exec-2] o.s.c.c.s.NativeEnvironmentRepository    : Adding property source: file:/Users/sgibb/workspace/spring/spring-cloud-samples/configserver/target/config/foo.properties
2015-04-08 12:22:54.099  INFO 85076 --- [nio-8888-exec-2] o.s.c.c.s.NativeEnvironmentRepository    : Adding property source: file:/Users/sgibb/workspace/spring/spring-cloud-samples/configserver/target/config/application.yml
2015-04-08 12:22:54.099  INFO 85076 --- [nio-8888-exec-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@416d044c: startup date [Wed Apr 08 12:22:54 EDT 2015]; root of context hierarchy
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29513596

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档