我想使用java buildpack在cloudfoundry上运行一个spring应用程序作为一次性任务。
请注意,我的应用程序不是 Web 应用程序,而是同样使用 Spring Cloud 任务的 Spring Batch 应用程序。
这是我的清单:
---
buildpack: https://github.com/cloudfoundry/java-buildpack.git
memory: 1024M
env:
APPLICATION_URL: http://bignibou-server.cfapps.io/
APPLICATION_MAIL_NO_REPLY_ADDRESS: balteo@bignibou-server.cfapps.io
SPRING_PROFILES_ACTIVE: cloud
applications:
- name: bignibou-server
path: bignibou-server/build/libs/bignibou-server.jar
env:
APPLICATION_GOOGLE_API_KEY: ******************
- name: bignibou-batch
path: bignibou-batch/build/libs/bignibou-batch.jar
no-hostname: true
no-route: true
command: null
health-check-type: none
env:
JAVA_OPTS: -Dspring.batch.job.names=messagesDigestMailingJob
每当我推送应用程序时,它都会被检测为工作应用程序:
App bignibou-batch is a worker, skipping route creation
这就是我想要的。
但随后它尝试将批处理作为 Web 应用程序启动(仍在部署应用程序时)......请参阅:
2017-03-24T22:33:50.828+01:00 [CELL/0] [OUT] Destroying container
2017-03-24T22:33:50.854+01:00 [API/3] [OUT] Process has crashed with type: "web"
2017-03-24T22:33:50.873+01:00 [API/3] [OUT] App instance exited with guid befc8bf2-d338-45e1-90b9-430ff3b09a3f payload: {"instance"=>"", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"2 error(s) occurred:\n\n* Codependent step exited\n* cancelled", "crash_count"=>1, "crash_timestamp"=>1490391230813627797, "version"=>"8f92e459-a6c7-4558-bc0b-09ac398eb069"}
2017-03-24T22:33:51.473+01:00 [CELL/0] [OUT] Successfully destroyed container
2017-03-24T22:33:51.634+01:00 [CELL/0] [OUT] Creating container
2017-03-24T22:33:52.478+01:00 [CELL/0] [OUT] Successfully created container
2017-03-24T22:33:56.824+01:00 [APP/PROC/WEB/0] [OUT] JVM Memory Configuration: -XX:MaxMetaspaceSize=164239K -XX:ReservedCodeCacheSize=240M -XX:CompressedClassSpaceSize=25984K -Xmx295151K -XX:MaxDirectMemorySize=10M
2017-03-24T22:33:56.827+01:00 [APP/PROC/WEB/0] [ERR] JVM Memory Configuration: -XX:ReservedCodeCacheSize=240M -XX:CompressedClassSpaceSize=25984K -Xmx295151K -XX:MaxDirectMemorySize=10M -XX:MaxMetaspaceSize=164239K
2017-03-24T22:33:59.073+01:00 [APP/PROC/WEB/0] [OUT] . ____ _ __ _ _
2017-03-24T22:33:59.073+01:00 [APP/PROC/WEB/0] [OUT] /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
2017-03-24T22:33:59.073+01:00 [APP/PROC/WEB/0] [OUT] \\/ ___)| |_)| | | | | || (_| | ) ) ) )
2017-03-24T22:33:59.073+01:00 [APP/PROC/WEB/0] [OUT] ' |____| .__|_| |_|_| |_\__, | / / / /
2017-03-24T22:33:59.073+01:00 [APP/PROC/WEB/0] [OUT] =========|_|==============|___/=/_/_/_/
2017-03-24T22:33:59.073+01:00 [APP/PROC/WEB/0] [OUT] ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2017-03-24T22:33:59.075+01:00 [APP/PROC/WEB/0] [OUT] :: Spring Boot :: (v1.5.2.RELEASE)
2017-03-24T22:33:59.266+01:00 [APP/PROC/WEB/0] [OUT] 2017-03-24 21:33:59.256 INFO 16 --- [ main] pertySourceApplicationContextInitializer : Adding 'cloud' PropertySource to ApplicationContext
2017-03-24T22:33:59.381+01:00 [APP/PROC/WEB/0] [OUT] 2017-03-24 21:33:59.359 WARN 16 --- [ main] o.c.r.o.s.cloud.AbstractCloudConnector : No suitable service info creator found for service elasticsearch Did you forget to add a ServiceInfoCreator?
2017-03-24T22:33:59.389+01:00 [APP/PROC/WEB/0] [OUT] 2017-03-24 21:33:59.388 INFO 16 --- [ main] nfigurationApplicationContextInitializer : Adding cloud service auto-reconfiguration to ApplicationContext
2017-03-24T22:33:59.465+01:00 [APP/PROC/WEB/0] [OUT] 2017-03-24 21:33:59.451 INFO 16 --- [ main] com.bignibou.batch.Batch : Starting Batch on a1e87528-637d-4dae-62ab-0538e48fb49b with PID 16 (/home/vcap/app/BOOT-INF/classes started by vcap in /home/vcap/app)
这不是我想要的...
所以我的问题是:
- 如何配置我的清单以便在不自动启动的情况下正确推送批处理应用程序 - 我只想将二进制文件推送到 cf 以便稍后运行任务...
- 如何在 cloudfoundry 上将我的 spring 批处理作为 cf 任务启动?