forked from cunningham-lab/neurocaas_contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_main.sh
executable file
·61 lines (52 loc) · 2.18 KB
/
run_main.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
#!/bin/bash
## Bash script that establishes ncap monitoring routines with minimal dependencies on other packages.
## Load in helper functions.
execpath="$0"
scriptpath="$(dirname "$execpath")/ncap_utils"
## Get in absolute path loader:
source "$scriptpath/paths.sh"
## Now declare remote directory name for here and all sourced files:
set -a
neurocaasrootdir=$(dirname $(get_abs_filename "$execpath"))
userhome="/home/ubuntu"
set +a
source "$scriptpath/workflow.sh"
## Import functions for data transfer
source "$scriptpath/transfer.sh"
## Now parse arguments in to relevant variables. These will be available to all scripts run from within.
# Bucket Name $bucketname
# Group Directory $groupdir
# Results Directory $resultdir
# Analysis Output Directory $process
# Dataset Name (without path) $dataname
# Dataset Full Path $inputpath (fka $datapath)
# Configuration Name # configname
# Configuration Path # configpath
set -a
parseargsstd "$1" "$2" "$3" "$4"
set +a
echo $bucketname >> "/home/ubuntu/check_vars.txt"
echo $groupdir >> "/home/ubuntu/check_vars.txt"
echo $resultdir >> "/home/ubuntu/check_vars.txt"
echo $processdir >> "/home/ubuntu/check_vars.txt"
echo $dataname >> "/home/ubuntu/check_vars.txt"
echo $inputpath >> "/home/ubuntu/check_vars.txt"
echo $configname >> "/home/ubuntu/check_vars.txt"
echo $configpath >> "/home/ubuntu/check_vars.txt"
## Set up Error Status Reporting:
errorlog_init
## Set up STDOUT and STDERR Monitoring:
errorlog_background &
background_pid=$!
echo $background_pid, "is the pid of the background process"
## MAIN SCRIPT GOES HERE #####################
#bash wait 20 # "$5" #/home/ubuntu/ncap_remote/run_yass.sh
bash "$5" > "$neurocaasrootdir"/joboutput.txt 2>"$neurocaasrootdir"/joberror.txt
##############################################
## Cleanup: figure out how the actual processing went.
## MUST BE RUN IMMEDIATELY AFTER PROCESSING SCRIPTS TO GET ERROR CODE CORRECTLY.
errorlog_final
## Once this is all over, send the config and end.txt file
aws s3 cp s3://"$bucketname"/"$configpath" s3://"$bucketname"/"$groupdir"/"$processdir"/$configname
aws s3 cp "$neurocaasrootdir"/update.txt s3://"$bucketname"/"$groupdir"/"$processdir"/
kill "$background_pid"