-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartup.sh
executable file
·36 lines (31 loc) · 1.01 KB
/
startup.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
#!/bin/bash
#
# This script supports the following environment vars:
# - WEB_MEMORY: the amount of memory each
# process is expected to consume, in MB.
# - NODEJS_V8_ARGS: any additional args to
# pass to the v8 runtime.
node_args="index.js --color"
if [[ -n "$WEB_MEMORY" ]]; then
if [ $WEB_MEMORY -le 512 ]; then
node_args="--max_semi_space_size=2 $node_args"
elif [ $WEB_MEMORY -le 768 ]; then
node_args="--max_semi_space_size=8 $node_args"
elif [ $WEB_MEMORY -le 1024 ]; then
node_args="--max_semi_space_size=16 $node_args"
fi
mem_node_old_space=$((($WEB_MEMORY*4)/5))
#mem_node_old_space=$(($WEB_MEMORY/2))
node_args="--max_old_space_size=$mem_node_old_space $node_args"
fi
if [[ -n "$NODEJS_V8_ARGS" ]]; then
# Pass any additional arguments to v8.
node_args="$NODEJS_V8_ARGS $node_args"
fi
echo "Starting app:"
echo "> node $node_args"
# Start the process using `exec`.
# This ensures that when node exits,
# the exit code is passed up to the
# caller of this script.
exec node $node_args