frennkie / django-ip2tor

Django Lightning Enabled Shop
19 stars 6 forks source link

Installation process #2

Open openoms opened 4 years ago

openoms commented 4 years ago

Aiming to follow the install process on a clean Debian 10 image.

getting stuck at:

(venv) debian@ip2t:/var/www/sites/site_django_ip2tor/ip2tor_shop$ daphne django_ip2tor.asgi:application --port 8001 --proxy-headers
Traceback (most recent call last):
  File "/var/www/sites/site_django_ip2tor/venv/bin/daphne", line 8, in <module>
    sys.exit(CommandLineInterface.entrypoint())
  File "/var/www/sites/site_django_ip2tor/venv/lib/python3.7/site-packages/daphne/cli.py", line 191, in entrypoint
    cls().run(sys.argv[1:])
  File "/var/www/sites/site_django_ip2tor/venv/lib/python3.7/site-packages/daphne/cli.py", line 252, in run
    application = import_by_path(args.application)
  File "/var/www/sites/site_django_ip2tor/venv/lib/python3.7/site-packages/daphne/utils.py", line 12, in import_by_path
    target = importlib.import_module(module_path)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "./django_ip2tor/asgi.py", line 18, in <module>
    django.setup()
  File "/var/www/sites/site_django_ip2tor/venv/lib/python3.7/site-packages/django/__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/var/www/sites/site_django_ip2tor/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 76, in __getattr__
    self._setup(name)
  File "/var/www/sites/site_django_ip2tor/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 63, in _setup
    self._wrapped = Settings(settings_module)
  File "/var/www/sites/site_django_ip2tor/venv/lib/python3.7/site-packages/django/conf/__init__.py", line 142, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'django_ip2tor.settings_prod'

When this file: django_ip2tor.settings_prod supposed to be created?

frennkie commented 4 years ago

My bad.. I wanted to write docs.. But didn't get to it. Basically you can create an empty settings_prod.py file and put this in:

from . settings import *
SECRET_KEY = <GENERATED KEY HERE>

The reason for this was to have a way to override Django SECRET_KEY from the one being checked into this repo.

frennkie commented 4 years ago

I managed to add the missing part for the installation on a Bridge Host: https://github.com/frennkie/django-ip2tor#installation-on-a-host

This is really simple and straight forward (as intended).

The Django stuff (especially the settings_prod.py thing) needs some reconsideration.

frennkie commented 4 years ago

Regarding the (secret)/local settings I'm looking at this https://github.com/joke2k/django-environ or this https://github.com/sloria/environs.

I extensively updated the shop installation documentation yesterday.

frennkie commented 4 years ago

Now (dbfe35f974df4993373165911b4d8219895f3a1f) all that is needed is to fill the environment or put a .env file in the root directory.

ToDo: Update docs

frennkie commented 4 years ago

@openoms I decided to use a dedicated user (ip2tor) to run the services and simply install it in the home directory. This is now pretty similar to the way we setup apps on RaspiBlitz. Would be great if you could review/test the current instructions and files for the Shop installation.