Remove unused scripts

These were referenced by appspec and have not been used since we
migrated to paas, so they can be removed.
This commit is contained in:
Athanasios Voutsadakis
2018-01-02 14:25:40 +00:00
parent 806e880ec2
commit 2470faf04b
9 changed files with 0 additions and 314 deletions

View File

@@ -1,8 +0,0 @@
#!/bin/bash
set -eo pipefail
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,10 +0,0 @@
#!/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 -p /home/notify-app/notifications-api
fi

View File

@@ -1,8 +0,0 @@
#!/bin/bash
set -eo pipefail
echo "Install dependencies"
cd /home/notify-app/notifications-api;
pip3 install -r /home/notify-app/notifications-api/requirements.txt

View File

@@ -1,8 +0,0 @@
#!/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,20 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
function start
{
service=$1
if [ -e "/etc/init/${service}.conf" ]
then
echo "Starting ${service}"
service ${service} start
fi
}
start "notifications-api"
start "notifications-api-celery-worker"
start "notifications-api-celery-worker-sender"
start "notifications-api-celery-worker-research"
start "notifications-api-celery-worker-db"
start "notifications-api-celery-beat"

View File

@@ -1,23 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail
function stop
{
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
}
stop "notifications-api"
stop "notifications-api-celery-beat"
stop "notifications-api-celery-worker"
stop "notifications-api-celery-worker-sender"
stop "notifications-api-celery-worker-research"
stop "notifications-api-celery-worker-db"

View File

@@ -1,77 +0,0 @@
#!/bin/bash
#
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
. $(dirname $0)/common_functions.sh
msg "Running AWS CLI with region: $(get_instance_region)"
# get this instance's ID
INSTANCE_ID=$(get_instance_id)
if [ $? != 0 -o -z "$INSTANCE_ID" ]; then
error_exit "Unable to get this instance's ID; cannot continue."
fi
# Get current time
msg "Started $(basename $0) at $(/bin/date "+%F %T")"
start_sec=$(/bin/date +%s.%N)
msg "Getting relevant load balancer"
INSTANCE_NAME=$(get_instance_name_from_tags $INSTANCE_ID)
if [[ "$(tr [:upper:] [:lower:] <<< "${INSTANCE_NAME}")" =~ 'delivery' ]]; then
msg "NO ELBs for delivery"
exit 0
fi
get_elb_name_for_instance_name $INSTANCE_NAME
get_elb_list $INSTANCE_ID $ELB_NAME
msg "Checking that user set at least one load balancer"
if test -z "$ELB_LIST"; then
error_exit "Must have at least one load balancer to deregister from"
fi
# Loop through all LBs the user set, and attempt to deregister this instance from them.
for elb in $ELB_LIST; do
msg "Checking validity of load balancer named '$elb'"
validate_elb $INSTANCE_ID $elb
if [ $? != 0 ]; then
msg "Error validating $elb; cannot continue with this LB"
continue
fi
msg "Deregistering $INSTANCE_ID from $elb"
deregister_instance $INSTANCE_ID $elb
if [ $? != 0 ]; then
error_exit "Failed to deregister instance $INSTANCE_ID from ELB $elb"
fi
done
# Wait for all Deregistrations to finish
msg "Waiting for instance to de-register from its load balancers"
for elb in $ELB_LIST; do
wait_for_state "elb" $INSTANCE_ID "OutOfService" $elb
if [ $? != 0 ]; then
error_exit "Failed waiting for $INSTANCE_ID to leave $elb"
fi
done
msg "Finished $(basename $0) at $(/bin/date "+%F %T")"
end_sec=$(/bin/date +%s.%N)
elapsed_seconds=$(echo "$end_sec - $start_sec" | /usr/bin/bc)
msg "Elapsed time: $elapsed_seconds"

View File

@@ -1,78 +0,0 @@
#!/bin/bash
#
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
. $(dirname $0)/common_functions.sh
msg "Running AWS CLI with region: $(get_instance_region)"
# get this instance's ID
INSTANCE_ID=$(get_instance_id)
if [ $? != 0 -o -z "$INSTANCE_ID" ]; then
error_exit "Unable to get this instance's ID; cannot continue."
fi
# Get current time
msg "Started $(basename $0) at $(/bin/date "+%F %T")"
start_sec=$(/bin/date +%s.%N)
msg "Getting relevant load balancer"
INSTANCE_NAME=$(get_instance_name_from_tags $INSTANCE_ID)
if [[ "$(tr [:upper:] [:lower:] <<< "${INSTANCE_NAME}")" =~ 'delivery' ]]; then
msg "NO ELBs for delivery"
exit 0
fi
get_elb_name_for_instance_name $INSTANCE_NAME
ELB_LIST=$ELB_NAME
get_elb_list $INSTANCE_ID $ELB_NAME
msg "Checking that user set at least one load balancer"
if test -z "$ELB_LIST"; then
error_exit "Must have at least one load balancer to register to"
fi
# Loop through all LBs the user set, and attempt to register this instance to them.
for elb in $ELB_LIST; do
msg "Checking validity of load balancer named '$elb'"
validate_elb $INSTANCE_ID $elb
if [ $? != 0 ]; then
msg "Error validating $elb; cannot continue with this LB"
continue
fi
msg "Registering $INSTANCE_ID to $elb"
register_instance $INSTANCE_ID $elb
if [ $? != 0 ]; then
error_exit "Failed to register instance $INSTANCE_ID from ELB $elb"
fi
done
# Wait for all Registrations to finish
msg "Waiting for instance to register to its load balancers"
for elb in $ELB_LIST; do
wait_for_state "elb" $INSTANCE_ID "InService" $elb
if [ $? != 0 ]; then
error_exit "Failed waiting for $INSTANCE_ID to return to $elb"
fi
done
msg "Finished $(basename $0) at $(/bin/date "+%F %T")"
end_sec=$(/bin/date +%s.%N)
elapsed_seconds=$(echo "$end_sec - $start_sec" | /usr/bin/bc)
msg "Elapsed time: $elapsed_seconds"

View File

@@ -1,82 +0,0 @@
#!/usr/bin/env python3
"""
Scipt used to stop celery in AWS environments.
This is used from upstart to issue a TERM signal to the master celery process.
This will then allow the worker threads to stop, after completing
whatever tasks that are in flight.
Note the script blocks for up to 15minutes, which is long enough to allow our
longest possible task to complete. If it can return quicker it will.
Usage:
./stop_celery.py <celery_pid_file>
Example:
./stop_celery.py /tmp/celery.pid
"""
import os
from docopt import docopt
import re
import subprocess
from time import sleep
def strip_white_space(from_this):
return re.sub(r'\s+', '', from_this)
def get_pid_from_file(filename):
"""
Open the file which MUST contain only the PID of the master celery process.
This is written to disk by the start celery command issued by upstart
"""
with open(filename) as f:
celery_pid = f.read()
return strip_white_space(celery_pid)
def issue_term_signal_to_pid(pid, celery_pid_file):
"""
Issues a TERM signal (15) to the master celery process.
This method attempts to print out any response from this subprocess call. However this call is generally silent.
"""
print("Trying to stop ", celery_pid_file)
result = subprocess.Popen(['kill', '-15', pid], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
for line in result.stdout.readlines():
print(line.rstrip())
for line in result.stderr.readlines():
print(line.rstrip())
def pid_still_running(pid):
"""
uses the proc filesystem to identify if the celery master pid is still around.
Once the process stops this file no longer exists. Slim possibilty of a race condition here.
"""
return os.path.exists("/proc/" + pid)
if __name__ == "__main__":
arguments = docopt(__doc__)
celery_pid_file = arguments['<celery_pid_file>']
celery_pid = get_pid_from_file(celery_pid_file)
issue_term_signal_to_pid(celery_pid, celery_pid_file)
"""
Blocking loop to check for the still running process.
5 seconds between loops
180 loops
Maximum block time of 900 seconds (15 minutes)
"""
iteration = 0
while pid_still_running(celery_pid) and iteration < 180:
print("[", celery_pid_file, "] waited for ", iteration * 5, " secs")
sleep(5)
iteration += 1