forked from helpyio/helpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·36 lines (28 loc) · 776 Bytes
/
run.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
set -euo pipefail
IFS=$'\n\t'
SLEEPSECONDS=5
echo "waiting $SLEEPSECONDS seconds for postgres.."
# sleep while postgres is initializing
sleep $SLEEPSECONDS
pg_isready -q -h postgres
ISREADY=$?
while [[ "$ISREADY" != 0 ]]; do
pg_isready -q -h postgres
let ISREADY=$?
echo "waiting $SLEEPSECONDS seconds for postgres.."
sleep $SLEEPSECONDS
done
echo "postgres is now avaliable"
RUN_PREPARE=${DO_NOT_PREPARE:-false}
if [[ "$RUN_PREPARE" = "false" ]]
then
echo "DO_NOT_PREPARE is not set or is false, preparing.."
bundle exec rake assets:precompile
bundle exec rake db:migrate
bundle exec rake db:seed || echo "db is already seeded"
fi
echo "starting puma"
mkdir -p log
touch log/production.log
exec bundle exec puma -C config/puma.rb