-
Notifications
You must be signed in to change notification settings - Fork 1
/
shutdown.sh
69 lines (49 loc) · 2.01 KB
/
shutdown.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
##optionally can specify the run parameters
PROJECT=$(gcloud config get-value project)
CLOUDSHELL=$(hostname | grep '^cs' | wc -l )
echo "CLOUDSHELL "$cloudshell
OPTION=$1
export RESNAME=$2
if [ ! $1 ] || [ ! $2 ]; then
echo "usage bash shutdown.sh|bwa-species|mm2-species|bwa-resistance|mm2-resistance res_prefix"
exit 1
else
paramsfile="parameters/params-${OPTION}-${RESNAME}"
fi
cd $HOME
if [ -e "./github" ]; then cd github ; fi
mkdir -p parameters
#gsutil rsync -d parameters gs://$PROJECT/parameters
gsutil cp gs://$PROJECT/${paramsfile} ${paramsfile}
if [ ! -e $paramsfile ] ; then
echo "${paramsfile} does not exist"
exit 1;
fi
source $paramsfile
if [ ! $ALIGNER_REGION ]; then
echo "please define global parameter ALIGNER_REGION using e.g. export ALIGNER_REGION=\"asia-northeast1\""
exit 1;
fi
if [ ! $UPLOAD_SUBSCRIPTION ]; then
echo "please define UPLOAD_SUBSCRIPTION"
exit 1;
fi
if [ $JOBID ]; then
gcloud dataflow jobs list | grep ${JOBID} | cut -f 1 -d ' ' | xargs -I {} gcloud dataflow jobs --project=$PROJECT cancel --region=$ALIGNER_REGION {}
else
gcloud dataflow jobs list | grep Running | cut -f 1 -d ' ' | xargs -I {} gcloud dataflow jobs --project=$PROJECT cancel --region=$ALIGNER_REGION {}
fi
#DE-COMMISSION ALIGNER
source ./gcloud/aligner/provision_internal.sh
cleanup
#CLOSE SUBSCRIPTION
echo "gcloud pubsub subscriptions list | grep name | grep ${UPLOAD_SUBSCRIPTION} | cut -f 2 -d ' ' | xargs -I {} gcloud pubsub subscriptions delete {}"
gcloud pubsub subscriptions list | grep 'name' | grep ${UPLOAD_SUBSCRIPTION} | cut -f 2 -d ' ' | xargs -I {} gcloud pubsub subscriptions delete {}
## DELETES ALL NOTIFICATIONS - but no reason to do this, other pipelines could be using it
#source ../pubsub/delete_all_notifications.sh
dinfo=$(stat --printf='%Y\t%n\n' $paramsfile | cut -f 1)
mv $paramsfile $paramsfile.${dinfo}
gsutil cp ${paramsfile}.${dinfo} gs://$PROJECT/$paramsfile.${dinfo}
gsutil rm gs://$PROJECT/${paramsfile}
#gsutil rsync -d parameters gs://$PROJECT/parameters