forked from ttrahan-beta/box
-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.sh
executable file
·38 lines (36 loc) · 900 Bytes
/
boot.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
#!/bin/bash
checkEnvironmentVariables() {
echo 'Checking for required environment variables....'
if [[ -z $DB_USERNAME ]]; then
echo 'DB_USERNAME not found. Exiting.'
exit 1;
elif [[ -z $DB_PASSWORD ]]; then
echo 'DB_PASSWORD not found. Exiting.'
exit 1;
elif [[ -z $DB_HOST ]]; then
echo 'DB_HOST not found. Exiting.'
exit 1;
elif [[ -z $DB_PORT ]]; then
echo 'DB_PORT not found. Exiting.'
exit 1;
elif [[ -z $DB_NAME ]]; then
echo 'DB_NAME not found. Exiting.'
exit 1;
fi
echo 'All variables are present.'
}
exportVariables() {
export readonly RANDOM_NUMBER=$(date +%s-%N)
export readonly DB_URL="mongodb://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}"
}
startCron() {
cd /home/demo/box
echo 'cron running without forever'
node cron.js
}
main() {
checkEnvironmentVariables
exportVariables
startCron
}
main