-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstart
executable file
·103 lines (80 loc) · 1.96 KB
/
start
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env bash
#
# Global variables.
#
APP="app"
CONFIG="config"
BUNDLE="build/bundle"
if [ -z "$METEOR_SRC" ]; then
METEOR_SRC="$HOME/src/meteor"
fi
#
# Help and usage info.
#
display_help() {
cat <<-EOF
A utility for running your Meteor applications.
Usage: start [options]
Options:
--help Display help
--checkout Use a Meteor git checkout
--env <env> Set the environment (development, test, production)
--packages <path> Tell Meteor about another packages folder
EOF
exit 0
}
#
# Start your application.
#
start() {
if [ -z "$NODE_ENV" ]; then
NODE_ENV="development"
fi
local env_file="$CONFIG/$NODE_ENV/env.sh";
local settings_file="$CONFIG/$NODE_ENV/settings.json";
if [ -f "$env_file" ]; then source "$env_file"; fi
if [ -f "$settings_file" ]; then
export METEOR_SETTINGS="$(cat $settings_file)"
fi
if [ "$CHECKOUT" ]; then
if [ ! -d "$METEOR_SRC" ]; then
echo "Error: To run from a git checkout of meteor, please set the METEOR_SRC env variable to a valid meteor source folder."
exit 1;
fi
echo "Using a Meteor git checkout."
METEOR="$METEOR_SRC/meteor"
else
METEOR="meteor"
fi
if [ "$NODE_ENV" == "production" ]; then
cd "$BUNDLE"
echo "Installing server npm packages..."
(cd programs/server && npm install)
echo "Starting your app in $NODE_ENV on port $PORT"
node main.js
else
cd "$APP"
echo "Starting your app in $NODE_ENV."
local CMD="$METEOR --settings ../$settings_file"
echo "$CMD"
eval $CMD
fi
}
#
# Handle arguments.
#
if [ $# -eq 0 ]; then
start
else
while [ $# -ne 0 ]; do
case $1 in
-h|--help|help) display_help ;;
-e|--env) export NODE_ENV="$2"; shift ;;
--checkout) CHECKOUT=true ;;
--packages) export PACKAGE_DIRS="$2:$PACKAGE_DIRS"; shift ;;
*) display_help ;;
esac
shift
done
start $1
fi