Skip to content

Commit

Permalink
refactor(script): debug in production friendly scripts setup
Browse files Browse the repository at this point in the history
fix(scripts): make manage.py script executable

sorry was making it on windows

fix(scripts): more executables

same like above

fix(cfg): env stuff fix

fix(scripts): add shebang
  • Loading branch information
hUwUtao committed May 26, 2024
1 parent c22fce9 commit ee36a41
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,5 @@ pip-selfcheck.json
# End of https://www.toptal.com/developers/gitignore/api/python,virtualenv,node
/media/
/static/
.coverage
.coverage
!scripts
6 changes: 3 additions & 3 deletions fuhoblog/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import os
from urllib.parse import urlparse

DEBUG = False or (
os.environ['DJANGO_DEBUG'] is not None and os.environ['DJANGO_DEBUG'] == 'True'
)
os.environ.setdefault('DJANGO_DEBUG', 'False')

DEBUG = False or (os.environ['DJANGO_DEBUG'] == 'True')

if SECRET_KEY == '':
print('no SECRET_KEY env')
Expand Down
8 changes: 7 additions & 1 deletion manage.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion run.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export DJANGO_SETTINGS_MODULE="fuhoblog.settings.production"
#!/bin/sh
source scripts/prod.env
rm -rv static
python manage.py collectstatic
python manage.py migrate --noinput
Expand Down
0 install.sh → scripts/install.sh
100644 → 100755
File renamed without changes.
2 changes: 2 additions & 0 deletions scripts/prod.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export DJANGO_SETTINGS_MODULE=fuhoblog.settings.production
export DJANGO_FORCEPROD="True"

0 comments on commit ee36a41

Please sign in to comment.