I am trying to deploy code from GitHub to CodeDeploy in AWS Amazon. I have sample HelloWorld application.I have appspec.yml that looks like this:
os: linux
files:
- source: /
destination: /home/ec2-user/server
permissions:
- object: /
pattern: "**"
owner: ec2-user
group: ec2-user
hooks:
ApplicationStop:
- location: stop.sh
timeout: 20
runas: ec2-user
ApplicationStart:
- location: start.sh
timeout: 20
runas: ec2-user
ValidateService:
- location: validate.sh
timeout: 120
runas: ec2-user
and buldspec.yml:
phases:
install:
runtime-versions:
java: openjdk8
build:
commands:
- mvn clean package --quiet
artifacts:
discard-paths: yes
files:
- target/*
- scripts/*
- appspec.yml
start.sh
cd /home/ec2-user/server
sudo /usr/bin/java -jar -Dserver.port=80 \
*.jar > /dev/null 2> /dev/null < /dev/null &
stop.sh:
#!/usr/bin/env bash
sudo killall java
exit 0
and validate.sh:
#!/bin/bash
echo "Waiting for 15 seconds before checking health.."
sleep 15
status_code=$(curl --write-out %{http_code} --silent --output /dev/null http://localhost:80)
if [[ "$status_code" -ne 200 ]] ; then
echo "App is not healthy - $status_code"
exit 1
else
echo "App is responding with $status_code"
exit 0
fi
My deployment failed and error says:
Script at specified location: start.sh run as user ec2-user failed with exit code 127 Logs LifecycleEvent - ApplicationStart Script - start.sh [stderr]/usr/bin/env: bash : No such file or directory
please can someone help me
#!/bin/bash
or#!/usr/bin/env bash
at the beginning of start.sh. Or is that a copy paste mistake? – Claudio Kuenzler