This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·62 lines (52 loc) · 1.84 KB
/
start.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
#!/bin/bash
# Starts the server
# @option --help Prints help message and exits with code 0
# @option -b / --build Runs ./build.sh before starting the server
function command_exists {
type -P "$1" 1> /dev/null 2> /dev/null;
}
# Check for options/arguments
for ((i=1; i<=$#; i++)); do
if [[ ${!i} = "--help" ]]; then
help="true"
elif [[ ${!i} = "-b" || ${!i} = "--build" ]]; then
build="true"
else
echo "Unrecognized Argument/Option '${!i}'"
exit 1
fi
done;
# Respond to inclusion of options/arguments
if [[ $help = "true" ]]; then
echo "Usage: ./start.sh [OPTION]..."
echo "Start the local application"
echo
echo "Miscellaneous:"
echo " -b, --build Build JavaScript files before starting application"
echo " --help Display this help text"
exit 0
fi
if [[ $build = "true" ]]; then
./build.sh # User can specify -b or --build in order to build JavaScript before starting the application
echo
fi
# authbind (I believe) creates a file named 'localhost:80' which blocks express from listening on port 80
test -e localhost:80 && rm localhost:80
if grep -- project_state ./src/config/config.json | grep -q -- production # If the "project_state" property in ./src/config.json is set to "production"
then
echo "Project state is set to production"
echo "JavaScript is ES2015-compatible"
echo
if command_exists authbind # authbind may not be present on the Heroku machine
then
authbind node ./src/build/app.js # Production
else # try without authbind
echo "[WARN] :: The 'authbind' program is not present"
node ./src/build/app.js
fi
else
echo "Project state is set to development"
echo
authbind node ./src/app.js # Development (ES2015-Compliant code is not needed in development)
fi
exit 0