From c0e97d60f599c3ae9322546998856bc2cf134bd3 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 fix(scripts): make manage.py script executable sorry was making it on windows --- .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(-) mode change 100644 => 100755 manage.py 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 old mode 100644 new mode 100755 index 444547c..cda5450 --- 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