This repository has been archived on 2021-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
greenlight/bin/start

38 lines
890 B
Plaintext
Raw Permalink Normal View History

2018-06-20 15:24:39 -04:00
#!/bin/bash
2018-07-30 15:42:45 -04:00
RUBYBIN=$HOME/.gem/ruby/2.7.0/bin
2021-02-21 02:16:15 -05:00
NODEBIN=$PWD/node_modules/.bin
export PATH=$RUBYBIN:$NODEBIN:$PATH
export RAILS_ENV=production
export BUNDLE_APP_CONFIG=$PWD/.bundle
if ! command -v bundle >/dev/null; then
gem install --user-install bundler
fi
if ! command -v yarn >/dev/null; then
npm install yarn
fi
2018-07-11 13:19:20 -04:00
if [ "$RAILS_ENV" = "production" ] && [ "$DB_ADAPTER" = "postgresql" ]; then
2018-07-30 15:42:45 -04:00
while ! curl http://$DB_HOST:${DB_PORT:-5432}/ 2>&1 | grep '52'
do
echo "Waiting for postgres to start up ..."
sleep 1
done
2018-07-09 13:17:23 -04:00
fi
2018-06-20 15:24:39 -04:00
db_create="$(RAILS_ENV=$RAILS_ENV bundle exec rake db:create 2>&1)"
2019-10-15 12:15:45 -04:00
echo $db_create
if [[ $db_create == *"already exists"* ]]; then
2019-10-15 12:15:45 -04:00
echo ">>> Database migration"
bundle exec rake db:migrate
else
echo ">>> Database initialization"
2019-10-15 12:58:11 -04:00
bundle exec rake db:schema:load
2018-07-05 17:25:59 -04:00
fi
2018-06-20 15:24:39 -04:00
bundle exec rake assets:precompile
2018-06-20 15:24:39 -04:00
exec bundle exec puma -C config/puma.rb