0
votes

Aws codedeploy is being applied. The appspec file is shown below.

version: 0.0
os: linux
files:
  - source: script/install-file.sh
    destination: /home/
hooks:
  AfterInstall:
    - location: script/install-file.sh
      timeout: 120
      runas: root
  ApplicationStart:
    - location: script/start-file.sh
      timeout: 120
      runas: root

I tried Succeeded until AfterInstall. It is still pending in applicationStart. AfterInstall installed Java files and set permissions.

chmod 755 ${file_HOME}/bin/install_api
chmod 755 ${file_HOME}/bin/install_web

Auto-run was set.

/bin/cp ${file_HOME}/bin/install_api /etc/init.d
/bin/cp ${file_HOME}/bin/install_web /etc/init.d

Chkconfig --add ib_api
Chkconfig --add ib_web

start-file.sh is below.

#!/bin/bash
# start InnerBeans
sudo service install_api start &
sleep 5
sudo service install_web start &
sleep 5
1
Can you provide more details? What was the error / result? Can you check the deployment logs to see what codedeploy ran so far? Here's how to find them: docs.aws.amazon.com/codedeploy/latest/userguide/…Asaf

1 Answers

1
votes

When calling background processes or daemons inside a LifeCycleEvent script codedeploy-agent (version OFFICIAL_1.0-1.1106_rpm) remains pending until 70 minutes timeout. First, try removing & like this:

#!/bin/bash
# start InnerBeans
sudo service install_api start
#sleep 5
sudo service install_web start
#sleep 5

If it still failing, you probably have background or daemonized processes inside the init script so you need to redirect outputs stdout and stderr.

Try:

#!/bin/bash
# start InnerBeans
sudo service install_api start > /dev/null 2>&1
#sleep 5
sudo service install_web start > /dev/null 2>&1
#sleep 5

That second way worked for me. I found the solution here: https://forums.aws.amazon.com/thread.jspa?messageID=626766&#626766 and here http://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting-deployments.html#troubleshooting-long-running-processes