init 570 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. set -e
  3. cd /app
  4. if [[ -z "$1" && -n "$WORKER_CMD" ]]; then
  5. set -- $WORKER_CMD
  6. fi
  7. source /scripts/setup_env
  8. if [[ -z "${DO_NOT_CREATE_DATABASE}" && -z "$1" ]]; then
  9. bundle exec rake db:create RAILS_ENV=${RAILS_ENV}
  10. fi
  11. if [ -z "$1" ]; then
  12. bundle exec rake db:migrate RAILS_ENV=${RAILS_ENV}
  13. fi
  14. if [[ -z "${DO_NOT_SEED}" && -z "$1" ]]; then
  15. set +e
  16. bundle exec rake db:seed RAILS_ENV=${RAILS_ENV}
  17. set -e
  18. fi
  19. if [ -z "$1" ]; then
  20. exec bundle exec unicorn -c config/unicorn.rb
  21. else
  22. exec bundle exec rails runner "$@" RAILS_ENV=${RAILS_ENV}
  23. fi