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?

gefragt vor 2 Jahren753 Aufrufe
1 Antwort
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
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen