run.sh.template 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. MODE=development
  2. export DB_BASE_DIR=/path/to/directory/where/db/will/be/created
  3. export UPLOAD_FOLDER=/path/where/contributions/will/be/uploaded
  4. export TM_URL=http://location/of/tm/to/tmx
  5. export DOC_URL=http://location/of/doc/to/tmx
  6. export ELASTICSEARCH_URL=http://location/of/elasticsearch
  7. export PROJECT_NAME="PROJECT_NAME"
  8. curl -X DELETE "$ELASTICSEARCH_URL/users"
  9. curl -X DELETE "$ELASTICSEARCH_URL/resources"
  10. mkdir -p "$DB_BASE_DIR" "$UPLOAD_FOLDER"
  11. # In development mode, delete the database and recreate it with a few test users and resources each time application is started
  12. if [[ "$MODE" == "development" ]]; then
  13. export FLASK_DEBUG=1
  14. export FLASK_APP=dev_run.py
  15. export FLASK_RUN_PORT=5000
  16. export DB_FILENAME="stor_dev"
  17. rm -rf "$DB_BASE_DIR/$DB_FILENAME.sqlite" "$UPLOAD_FOLDER/*"
  18. cp -r dev-res/* "$UPLOAD_FOLDER/"
  19. flask translate compile
  20. flask run
  21. # In staging_setup mode, create an empty database with just the user groups and an admin user set up
  22. # Note: this is not to be used for actual staging runs, but only to generate the empty database file
  23. elif [[ "$MODE" == "staging_setup" ]]; then
  24. export FLASK_APP=staging_setup.py
  25. export FLASK_RUN_PORT=5000
  26. export STAGING_SUPERUSER_EMAIL="superuser@test.com"
  27. export STAGING_SUPERUSER_PASSWORD="staging123!"
  28. export DB_FILENAME="stor_staging"
  29. rm -rf "$DB_BASE_DIR/$DB_FILENAME.sqlite"
  30. flask run
  31. # In production mode, migrate an existing database
  32. elif [[ "$MODE" == "production" ]]; then
  33. export FLASK_APP=run.py
  34. export DB_FILENAME="stor"
  35. flask translate compile
  36. gunicorn -c gunicorn.conf.py run:app
  37. fi