应用程序运行状况良好,直到 application.properties 与应用程序捆绑在一起。
下一步,将属性移动到配置存储库,并使用以下语句在 Cloud Foundry 中创建配置服务。
cf create-service -c '{ "git": { "uri": "https://bitbucket.company.com/scm/abcdefg/app-configs", "label": "master", "searchPaths": "TOPFOLDER/app-folder", "username": "abcdef", "password": "123456" } }' p-config-server standard company-appname-config-server
然后将依赖项添加到我的 java 应用程序 (build.gradle)
compile("io.pivotal.spring.cloud:spring-cloud-services-starter-config-client:${pivotalSpringCloud}")
compile("org.springframework.cloud:spring-cloud-dependencies:Camden.SR4")
重新部署,应用程序运行良好,具有正确的属性。 在日志中我看到
2017-04-24T08:10:48.16-0500 [APP/PROC/WEB/0]OUT 2017-04-24 13:10:48.162 INFO 19 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: https://config-d45c8d75-67f0-4031-804a-3a23cb139b4a.company.com
应用程序在不到 20 秒内启动。以下是日志(将 healthchecktimeout 从默认值增加到 180)。
2017-04-24T08:07:56.67-0500 [APP/PROC/WEB/0]OUT 2017-04-24 13:07:56.670 INFO 14 --- [ main] o.s.i.a.i.AmqpInboundChannelAdapter : started inbound
2017-04-24T08:07:56.67-0500 [APP/PROC/WEB/0]OUT 2017-04-24 13:07:56.670 INFO 14 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 2147483647
2017-04-24T08:07:56.74-0500 [APP/PROC/WEB/0]OUT 2017-04-24 13:07:56.742 INFO 14 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8008 (http)
2017-04-24T08:07:56.74-0500 [APP/PROC/WEB/0]OUT Running as daemon
2017-04-24T08:07:56.75-0500 [APP/PROC/WEB/0]OUT 2017-04-24 13:07:56.752 INFO 14 --- [ main] c.company.app.MainApplication : Started CoordinatorBotApplication in 16.636 seconds (JVM running for 17.211)
2017-04-24T08:08:06.91-0500 [APP/PROC/WEB/0]OUT 2017-04-24 13:08:06.915 DEBUG 14 --- [ask-scheduler-1] heduler$$EnhancerBySpringCGLIB$$cbc32e8f : []
2017-04-24T08:09:37.08-0500 [APP/PROC/WEB/0]OUT 2017-04-24 13:09:37.086 DEBUG 14 --- [ask-scheduler-1] heduler$$EnhancerBySpringCGLIB$$cbc32e8f : []
2017-04-24T08:10:40.65-0500 [CELL/0] ERR Timed out after 3m0s: health check never passed.
2017-04-24T08:10:40.65-0500 [CELL/0] OUT Exit status 0
2017-04-24T08:10:40.66-0500 [APP/PROC/WEB/0]OUT 2017-04-24 13:10:40.660 INFO 14 --- [ Thread-4] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5ae9a829: startup date [Mon Apr 24 08:07:44 CDT 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@15327b79 }
关闭日志后,我看到此错误,随后再次创建容器。
2017-04-24T08:10:40.76-0500 [APP/PROC/WEB/0]OUT 2017-04-24 13:10:40.762 INFO 14 --- [ Thread-4] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2017-04-24T08:10:41.17-0500 [APP/PROC/WEB/0]OUT Exit status 143
2017-04-24T08:10:41.18-0500 [CELL/0] OUT Destroying container
2017-04-24T08:10:41.20-0500 [API/1] OUT Process has crashed with type: "web"
2017-04-24T08:10:41.21-0500 [API/1] OUT App instance exited with guid dc395017-3770-4617-a439-2a0fd5fb6dda payload: {"instance"=>"", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"2 error(s) occurred:\n\n* 1 error(s) occurred:\n\n* Exited with status 4\n* 2 error(s) occurred:\n\n* cancelled\n* cancelled", "crash_count"=>1, "crash_timestamp"=>1493039441179549849, "version"=>"246e48d2-45fe-47ed-a1ee-d4b05bd6599e"}
2017-04-24T08:10:41.22-0500 [CELL/0] OUT Creating container
有什么建议吗? 做错事了吗? 我可以通过什么方式获得进一步的调试详细信息?
最佳答案
已解决。
该问题与我尝试使用启动属性使用的特定端口号有关。
最初,我独立运行此应用程序(由于我有多个启动应用程序,因此我计划在特定端口上运行每个应用程序。)
但在 PCF 中,我们不需要特定的端口,因为每个应用程序都在其具有不同唯一路由(组件+域)的容器上运行。
- 配置 config-service 使其能够 ping 默认端口。但这已被启动属性中的特定端口覆盖。
删除特定端口 - 解决了我的问题
关于spring-boot - cloud-foundry:ERR 1 秒后超时:健康检查从未通过,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43590027/