#!/usr/bin/env bash set -eo pipefail app_root="$( cd "$(dirname "$0")/.."; pwd )" app_name="fizzy" # Use application binstubs export PATH="$app_root/bin:$PATH" announce() { echo echo "--- $@" } announce "Installing dependencies" gem install bundler --conservative bundle check || bundle install if [[ $* == *--reset* ]]; then announce "Recreating database" rails db:reset else announce "Preparing database" rails db:prepare fi announce "Removing old logs and tempfiles" rails log:clear tmp:clear announce "Restarting services" rails restart if [ -d "$HOME/.puma-dev" ]; then announce "Configuring puma-dev" ln -nfs "$app_root" "$HOME/.puma-dev/$app_name" announce "Checking https://$app_name.test/up" curl -Is "https://$app_name.test/up" | head -n 1 fi