How to start a long running process using AWS CodeDeploy hooks?

0

I have an appspec file where I am trying to start a long running Java service in an EC2 instance using AWS Code Deploy. But it seems the code deploy agent expects the script to eventually exit which won't happen for such a service unless I kill the service or perform a redeploy. And not exiting the command eventually fails the deployment.

Here is what my appspec.yml looks like

version: 0.0
os: linux
files:
  - source: /
    destination: /home/ubuntu/app
hooks:
  ApplicationStart:
    - location: bin/start-service.sh
      runas: ubuntu

And the contents of my start-service.sh looks like:

java -jar /home/ubuntu/app/target/app.jar 

which will not exit until I redeploy. How do I make the deployment succeed for such a service?

질문됨 2년 전753회 조회
1개 답변
0

Hello,

To be able to make a long process run is by configuring something like this

-->java -jar /home/ubuntu/app/target/app.jar > /dev/null 2> /dev/null < /dev/null &[1]

The reason for this being CodeDeploy doesn't like if process run in background and this will send it to null giving some code and CodeDeploy will pass the script

Reference:

[1]https://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting-deployments.html#troubleshooting-long-running-processes

AWS
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠