1
votes

I am trying to do auto deployment from bitbucket to an ec2 instance using codedeploy but Codedeploy always fails on "ApplicationStop" phase.

Here is my appspec.yml

version: 0.0 os: linux files: - source: /quickdeal.zip destination: /home/ubuntu/quickdeal/ hooks: BeforeInstall: - location: scripts/install_dependencies.sh runas: root ApplicationStop: - location: scripts/stop_server.sh runas: root ApplicationStart: - location: scripts/start_server.sh runas: root

and following is the stop_server.sh

#!/bin/bash
# stop any old running servers 
killall -s KILL node -q || echo 'no node process was running'

But this is the error I get in aws

Error CodeScriptFailed
Script Namescripts/stop_server.sh
MessageScript at specified location: scripts/stop_server.sh run as user root failed with exit code 1
Log TailLifecycleEvent - ApplicationStop
Script - scripts/stop_server.sh

Things I have already tried

[1] Deleted and re-created the application [2] Emptied stop_server.sh so that it doesn't give out any exit codes at all (still got exit code 1)

1
Since you have two problems, you should really have two separate SO questions. I'm going to edit your question to remove problem #2 and then I'll try to answer your first issue. - EmptyArsenal

1 Answers

1
votes

First off, when I try the killall command you have, it fails with:

killall: unknown signal q; valid signals:
HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM URG STOP
TSTP CONT CHLD TTIN TTOU IO XCPU XFSZ VTALRM PROF WINCH INFO USR1 USR2

As to the issue you discuss, I'm pretty confident is that scripts/stop_server.sh is not an executable. If the script is not executable, you'd get something like sudo: scripts/stop_server.sh: command not found if you tried to run it manually. Try to run the script locally, and I bet you'll see that.

It's an easy fix though. Run this on any executables that you'll be running in your appspec - sudo chmod +x scripts/stop_server.sh, and that should solve your issue when you create your new application bundle.