-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
78 lines (62 loc) · 2.07 KB
/
entrypoint.sh
File metadata and controls
78 lines (62 loc) · 2.07 KB
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
#!/bin/bash
mkdir -p /var/state/
chmod 666 -R /var/state/
# add the db_file_name
export DB_FILE="latest_record.db"
DB_FILE_PATH="$PWD/$DB_FILE"
export CONFIG_FILE="{collector_platform_name}-config.json"
CONFIG_FILE_PATH="$PWD/$CONFIG_FILE"
echo $AGENT_STATE_DIR
echo $DB_FILE_PATH
if [ -z "$AGENT_STATE_DIR" ]
then
# If there is no state directory configured, use the root directory to store the DB
echo "No state configured, keeping DB at application root"
# Create the file if it doesn't exist
if [ ! -f $DB_FILE_PATH ]
then
touch $DB_FILE_PATH
fi
else
# If an agent state directory is configured, use it instead
DB_FILE_PATH="$AGENT_STATE_DIR/$DB_FILE"
CONFIG_FILE_PATH="$AGENT_STATE_DIR/$CONFIG_FILE"
if [ -f $DB_FILE_PATH ]
then
# If the file exists already, do nothing
echo "DB file already exists, ignoring..."
else
# Otherwise make an empty db file in the state dir.
echo "Making empty DB file inside state directory $AGENT_STATE_DIR"
touch $DB_FILE_PATH
fi
fi
# Print the size of the DB file before migration
echo "Size of the DB file BEFORE MIGRATION:"
du -h $DB_FILE_PATH
# RUN DATABASE MIGRATION TO CONFIGURE DB FILE BEFORE STARTUP
echo "Creating DB schema"
alembic upgrade head
# Print the size of the DB file after migration
echo "Size of the DB file AFTER MIGRATION:"
du -h $DB_FILE_PATH
# Run a vacuum at startup
echo "Vacuuming DB $DB_FILE_PATH at startup..."
sqlite3 $DB_FILE_PATH "VACUUM"
# Print the size of the DB file after vacuum
echo "Size of the DB file AFTER VACUUM:"
du -h $DB_FILE_PATH
# Change it acccording to the collector
EXECUTION_ARGS=(--endDate "$END_DATE" --startDate "$START_DATE" --output-queue --input-queue --save-state)
# Include project root path
export PYTHONPATH=$(pwd)
echo "Starting running src/main.py"
if [ ${#EXECUTION_ARGS[@]} -eq 0 ]
then
echo "No input arguments supplied. Please provide input parameters."
python3 src/main.py --help
else
# echo $EXECUTION
echo "Starting script"
python3 -u src/main.py "${EXECUTION_ARGS[@]}"
fi