From 961f3940d659c3a835b61ecf894bc73ef9714168 Mon Sep 17 00:00:00 2001 From: stdpi Date: Sun, 26 May 2024 10:05:03 +0700 Subject: [PATCH] refactor(script): debug in production friendly scripts setup --- .gitignore | 3 ++- manage.py | 8 +++++++- run.sh | 2 +- install.sh => scripts/install.sh | 0 scripts/prod.env | 2 ++ 5 files changed, 12 insertions(+), 3 deletions(-) rename install.sh => scripts/install.sh (100%) create mode 100644 scripts/prod.env diff --git a/.gitignore b/.gitignore index 2023f58..9c4e663 100644 --- a/.gitignore +++ b/.gitignore @@ -325,4 +325,5 @@ pip-selfcheck.json # End of https://www.toptal.com/developers/gitignore/api/python,virtualenv,node /media/ /static/ -.coverage \ No newline at end of file +.coverage +!scripts \ No newline at end of file diff --git a/manage.py b/manage.py index 444547c..cda5450 100644 --- a/manage.py +++ b/manage.py @@ -3,7 +3,13 @@ import sys if __name__ == '__main__': - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'fuhoblog.settings.dev') + os.environ.setdefault('DJANGO_FORCEPROD', 'False') + os.environ.setdefault( + 'DJANGO_SETTINGS_MODULE', + 'fuhoblog.settings.dev' + if os.environ['DJANGO_FORCEPROD'] == 'False' + else 'fuhoblog.settings.production', + ) from django.core.management import execute_from_command_line diff --git a/run.sh b/run.sh index 61ce3c8..884f3a0 100644 --- a/run.sh +++ b/run.sh @@ -1,4 +1,4 @@ -export DJANGO_SETTINGS_MODULE="fuhoblog.settings.production" +source scripts/prod.env rm -rv static python manage.py collectstatic python manage.py migrate --noinput diff --git a/install.sh b/scripts/install.sh similarity index 100% rename from install.sh rename to scripts/install.sh diff --git a/scripts/prod.env b/scripts/prod.env new file mode 100644 index 0000000..22a95cd --- /dev/null +++ b/scripts/prod.env @@ -0,0 +1,2 @@ +DJANGO_SETTINGS_MODULE="fuhoblog.settings.production" +DJANGO_FORCEPROD="True" \ No newline at end of file