[英]How to start a long running JAR in CloudFormation cfn-init?
I am trying to start a Spring boot server with a JAR file. 我正在尝试使用JAR文件启动Spring引导服务器。 Generally this is executed with java -jar springboot.jar &
通常,这是使用java -jar springboot.jar &
However I am having trouble doing this using CloudFormation and this does not appear to work. 但是,我在使用CloudFormation进行此操作时遇到了麻烦,这似乎不起作用。
I am trying to do it in cfn-init
this way: 我正在尝试通过cfn-init
这样做:
"AWS::CloudFormation::Init" : {
"config" : {
"commands": {
"start_server": {
"command": "bash startup_script.sh &",
"cwd": "/home/ec2-user"
}
}
But the init does not go through. 但是初始化没有通过。
I think using userdata property of ec2 would suffice in this case. 我认为在这种情况下使用ec2的userdata属性就足够了。 However if you need more help in generating the cumbersome AWS::CloudFormation::Init object, you can use cloudkast which is an online cloudformation template generator. 但是,如果需要更多帮助来生成繁琐的AWS :: CloudFormation :: Init对象,则可以使用cloudkast ,它是一个在线cloudformation模板生成器。
A very simple way is to add a CreationPolicy
and set the time-out as needed 一种非常简单的方法是添加CreationPolicy
并根据需要设置超时
CreationPolicy:
ResourceSignal:
Count: '3'
Timeout: PT15M
Adjust as you need. 根据需要进行调整。 I've used this in cfn-init blocks that needed to do tasks that could take half an hour. 我在cfn-init块中使用了此功能,该块需要执行可能需要半小时的任务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.