forked from odtp-org/odtp-component-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
odtp-app.sh
81 lines (62 loc) · 2.53 KB
/
odtp-app.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
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
#########################################################
# ODTP COMPONENT TEMPLATE
#########################################################
echo "STARTING ODTP COMPONENT"
sleep 2
## ODTP LOGGER in the background
if [ -v ODTP_MONGO_SERVER ]; then
echo "STARTING LOGGING IN MONGO SERVER"
python3 /odtp/odtp-component-client/logger.py >> /odtp/odtp-logs/odtpLoggerDebugging.txt 2>&1 &
else
echo "ODTP_MONGO_SERVER does not exist"
fi
############################################################################################
# USER APP
############################################################################################
bash /odtp/odtp-app/app.sh
############################################################################################
# END OF USER APP
############################################################################################
#########################################################
# TRANSFERRING INPUT TO OUTPUT
#########################################################
if [ "$TRANSFER_INPUT_TO_OUTPUT" == "TRUE" ]; then
echo "COPYING INPUT FILES TO OUTPUT"
cp -r /odtp/odtp-input/* /odtp/odtp-output
fi
#########################################################
# COMPRESS THE OUTPUT FOLDER GENERATED
#########################################################
# Take output and export it
cd /odtp/odtp-output
zip -rq ../odtp-output.zip *
mv ../odtp-output.zip odtp-output.zip
#########################################################
# ODTP SNAPSHOT CREATION
#########################################################
# Take snapshot of workdir
if [ "ODTP_SAVE_SNAPSHOT" == "TRUE" ]; then
cd /odtp/odtp-workdir
zip -rq ../odtp-snapshot.zip *
mv ../odtp-snapshot.zip odtp-snapshot.zip
fi
## Saving Snapshot in s3
if [[ -v ODTP_S3_SERVER && -v ODTP_MONGO_SERVER ]]; then
echo "Uploading to ODTP_S3_SERVER"
python3 /odtp/odtp-component-client/s3uploader.py 2>&1 | tee /odtp/odtp-logs/odtpS3UploadedDebugging.txt
else
echo "ODTP_S3_SERVER does not exist"
fi
# ## Copying logs into output
# cp /odtp/odtp-logs/log.txt /odtp/odtp-output/log.txt
# if [ -v ODTP_S3_SERVER ]; then
# cp /odtp/odtp-logs/odtpLoggerDebugging.txt /odtp/odtp-output/odtpLoggerDebugging.txt
# else
# echo "ODTP_S3_SERVER doesn't exist. Not copying log files."
# fi
# if [[ -v ODTP_S3_SERVER && -v ODTP_MONGO_SERVER ]]; then
# cp /odtp/odtp-logs/odtpS3UploadedDebugging.txt /odtp/odtp-output/odtpS3UploadedDebugging.txt
# else
# echo "ODTP_S3_SERVER doesn't exist. Not copying log files."
# fi