#!/bin/sh if [ "$1" = "production" ]; then if [[ -f "/home/rails/app/tmp/pids/server.pid" ]];then rm /home/rails/app/tmp/pids/server.pid exit 1 fi #create databases it not exists $(bundle exec rails runner lib/database_exists.rb) if [ $? -eq 1 ]; then echo "setup database for $RAILS_ENV environment" bundle exec rails db:setup bundle exec rails db:migrate fi exec bundle exec rails server -b 0.0.0.0 fi exec "$@"