forked from opf/openproject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
web
executable file
·37 lines (32 loc) · 1.14 KB
/
web
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
#!/bin/bash -e
BIND="${BIND:=0.0.0.0}"
PORT="${PORT:=8080}"
RAILS_ENV="${RAILS_ENV:="development"}"
MIGRATE="${MIGRATE:="false"}"
MIN_INSTANCES="${PASSENGER_MIN_INSTANCES:=1}"
MAX_INSTANCES="${PASSENGER_MAX_INSTANCES:=3}"
SPAWN_METHOD="${PASSENGER_SPAWN_METHOD:=smart}"
USE_PUMA="${USE_PUMA:="false"}"
if [ "$RAILS_ENV" = "production" ] && [ "$USE_PUMA" = "true" ]; then
# @TODO Add apache config to serve the assets. Until then we have Puma serve
# them which is slower. This is ok if an asset host is used (SaaS).
# But for self-hosted installations we may want to fix that.
# Passenger does include a config to have nginx serve the assets.
export OPENPROJECT_ENABLE__INTERNAL__ASSETS__SERVER=true
fi
if [ "$MIGRATE" = "true" ]; then
echo "Migrating database..."
bundle exec rake db:migrate
fi
if [ "$USE_PUMA" = "true" ]; then
# see `config/puma.rb` for configuration
bundle exec rails server puma -b $BIND -p $PORT
else
exec bundle exec passenger start \
-p $PORT \
-a "${BIND}" \
--min-instances "$MIN_INSTANCES" \
--max-pool-size "$MAX_INSTANCES" \
--spawn-method "$SPAWN_METHOD" \
--max-preloader-idle-time 0
fi