Build db migration codedeploy artifact

This commit is contained in:
bandesz
2016-09-20 11:49:01 +01:00
parent d69a07fed9
commit 8ab7fa3395
9 changed files with 95 additions and 116 deletions

View File

@@ -1,13 +1,8 @@
#!/bin/bash
set -eo pipefail
if [ -e "/home/notify-app" ]
then
echo "Chown application to be owned by notify-app"
cd /home/notify-app/;
chown -R notify-app:govuk-notify-applications notifications-api
else
echo "Chown application to be owned by ubuntu"
cd /home/ubuntu/;
chown -R ubuntu:ubuntu notifications-api
fi
echo "Chown application to be owned by notify-app"
cd /home/notify-app/;
chown -R notify-app:govuk-notify-applications notifications-api

View File

@@ -1,15 +1,8 @@
#!/bin/bash
set -eo pipefail
echo "Install dependencies"
if [ -e "/home/notify-app" ]
then
echo "Depenencies for notify-app"
cd /home/notify-app/notifications-api;
pip3 install -r /home/notify-app/notifications-api/requirements.txt
python3 db.py db upgrade
else
echo "Depenencies for ubuntu"
cd /home/ubuntu/notifications-api;
pip3 install -r /home/ubuntu/notifications-api/requirements.txt
python3 db.py db upgrade
fi
cd /home/notify-app/notifications-api;
pip3 install -r /home/notify-app/notifications-api/requirements.txt

View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -eo pipefail
echo "Run database migrations"
cd /home/notify-app/notifications-api;
python3 db.py db upgrade

View File

@@ -1,31 +1,19 @@
#!/bin/bash
#!/usr/bin/env bash
if [ -e "/etc/init/notifications-api.conf" ]
then
echo "Starting api"
sudo service notifications-api start
fi
set -eo pipefail
if [ -e "/etc/init/notifications-api-celery-worker.conf" ]
then
echo "Starting celery worker"
sudo service notifications-api-celery-worker start
fi
function start
{
service=$1
if [ -e "/etc/init/${service}.conf" ]
then
echo "Starting ${service}"
service ${service} start
fi
}
if [ -e "/etc/init/notifications-api-celery-worker-sender.conf" ]
then
echo "Starting celery worker"
sudo service notifications-api-celery-worker-sender start
fi
if [ -e "/etc/init/notifications-api-celery-worker-db.conf" ]
then
echo "Starting celery worker"
sudo service notifications-api-celery-worker-db start
fi
if [ -e "/etc/init/notifications-api-celery-beat.conf" ]
then
echo "Starting celery beat"
sudo service notifications-api-celery-beat start
fi
start "notifications-api"
start "notifications-api-celery-worker"
start "notifications-api-celery-worker-sender"
start "notifications-api-celery-worker-db"
start "notifications-api-celery-beat"

View File

@@ -1,53 +1,22 @@
#!/bin/bash
#!/usr/bin/env bash
set -eo pipefail
function error_exit
function stop
{
echo "$1" 1>&2
exit 0
service=$1
if [ -e "/etc/init/${service}.conf" ]; then
echo "stopping ${service}"
if service ${service} stop; then
echo "${service} stopped"
else
>&2 echo "Could not stop ${service}"
fi
fi
}
if [ -e "/etc/init/notifications-api.conf" ]; then
echo "stopping notifications-api"
if sudo service notifications-api stop; then
echo "notifications-api stopped"
else
error_exit "Could not stop notifications-api"
fi
fi
if [ -e "/etc/init/notifications-api-celery-beat.conf" ]; then
echo "stopping notifications-api-celery-beat"
if sudo service notifications-api-celery-beat stop; then
echo "notifications-api beat stopped"
else
error_exit "Could not stop notifications-celery-beat"
fi
fi
if [ -e "/etc/init/notifications-api-celery-worker.conf" ]; then
echo "stopping notifications-api-celery-worker"
if sudo service notifications-api-celery-worker stop; then
echo "notifications-api worker stopped"
else
error_exit "Could not stop notifications-celery-worker"
fi
fi
if [ -e "/etc/init/notifications-api-celery-worker-sender.conf" ]; then
echo "stopping notifications-api-celery-worker-sender"
if sudo service notifications-api-celery-worker-sender stop; then
echo "notifications-api sender worker stopped"
else
error_exit "Could not stop notifications-celery-worker-sender"
fi
fi
if [ -e "/etc/init/notifications-api-celery-worker-db.conf" ]; then
echo "stopping notifications-api-celery-worker-db"
if sudo service notifications-api-celery-worker-db stop; then
echo "notifications-api db worker stopped"
else
error_exit "Could not stop notifications-celery-worker-db"
fi
fi
stop "notifications-api"
stop "notifications-api-celery-beat"
stop "notifications-api-celery-worker"
stop "notifications-api-celery-worker-sender"
stop "notifications-api-celery-worker-db"