From 383553b9646cadeef7d12f632ac469a42296ef46 Mon Sep 17 00:00:00 2001 From: Imdad Ahad Date: Mon, 13 Feb 2017 17:13:39 +0000 Subject: [PATCH 1/3] Remove notify app folder and installed python packages before we deploy the app --- appspec.yml | 4 ++++ scripts/aws_clear_instance.sh | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100755 scripts/aws_clear_instance.sh diff --git a/appspec.yml b/appspec.yml index a6455d55c..87a0f944a 100644 --- a/appspec.yml +++ b/appspec.yml @@ -5,6 +5,10 @@ files: - destination: /home/notify-app/notifications-api source: / hooks: + BeforeInstall: + - location: scripts/aws_clear_instance.sh + runas: root + timeout: 1000 AfterInstall: - location: scripts/aws_install_dependencies.sh runas: root diff --git a/scripts/aws_clear_instance.sh b/scripts/aws_clear_instance.sh new file mode 100755 index 000000000..b62397b06 --- /dev/null +++ b/scripts/aws_clear_instance.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +echo "Removing application and dependencies" + +if [ -d "/home/notify-app/notifications-api" ]; then + # Remove and re-create the directory + rm -rf /home/notify-app/notifications-api + mkdir -vp /home/notify-app/notifications-api + # Remove installed py3 packages + pip3 freeze | xargs pip3 uninstall -y +else + echo "Directory does not exist, something went wrong!" +fi + From 5ac3643d9d7da24f6c9ae87bbe43b9eaad44e934 Mon Sep 17 00:00:00 2001 From: Imdad Ahad Date: Tue, 14 Feb 2017 11:36:38 +0000 Subject: [PATCH 2/3] Cancel uninstalling all py3 packages --- scripts/aws_clear_instance.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/aws_clear_instance.sh b/scripts/aws_clear_instance.sh index b62397b06..645d07318 100755 --- a/scripts/aws_clear_instance.sh +++ b/scripts/aws_clear_instance.sh @@ -6,9 +6,5 @@ if [ -d "/home/notify-app/notifications-api" ]; then # Remove and re-create the directory rm -rf /home/notify-app/notifications-api mkdir -vp /home/notify-app/notifications-api - # Remove installed py3 packages - pip3 freeze | xargs pip3 uninstall -y -else - echo "Directory does not exist, something went wrong!" fi From 2e4b09154ed599c90774391398aa0176c96f33d1 Mon Sep 17 00:00:00 2001 From: Imdad Ahad Date: Tue, 14 Feb 2017 11:37:47 +0000 Subject: [PATCH 3/3] Remove verbose logging of directory creation --- scripts/aws_clear_instance.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/aws_clear_instance.sh b/scripts/aws_clear_instance.sh index 645d07318..9cdc14568 100755 --- a/scripts/aws_clear_instance.sh +++ b/scripts/aws_clear_instance.sh @@ -5,6 +5,6 @@ echo "Removing application and dependencies" if [ -d "/home/notify-app/notifications-api" ]; then # Remove and re-create the directory rm -rf /home/notify-app/notifications-api - mkdir -vp /home/notify-app/notifications-api + mkdir -p /home/notify-app/notifications-api fi