Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Trouble Setting up uWSGI + NGINX over socket #200

Open
1 of 2 tasks
liszca opened this issue Jul 29, 2021 · 1 comment
Open
1 of 2 tasks

Question: Trouble Setting up uWSGI + NGINX over socket #200

liszca opened this issue Jul 29, 2021 · 1 comment

Comments

@liszca
Copy link

liszca commented Jul 29, 2021

What I'm trying to do

Trying to run ImageTagger with uWSGI and NGINX over socket file

What I've tried

I first tried to follow this tutorial:
https://tonyteaches.tech/django-nginx-uwsgi-tutorial/

Additional context

In Tonys guide I am at 6. Get Nginx, uWSGI, and Django to Work Together testing my configuration.

after activating Venv I run following commands:

cd /var/django/it/imagetagger/imagetagger
uwsgi --socket /var/run/django/it.sock --module imagetagger.wsgi --chmod-socket=666

Output:

*** Starting uWSGI 2.0.19.1 (64bit) on [Thu Jul 29 10:46:05 2021] ***
compiled with version: 8.3.0 on 08 July 2021 20:46:10
os: Linux-5.4.124-1-pve #1 SMP PVE 5.4.124-1 (Wed, 23 Jun 2021 13:47:09 +0200)
nodename: it
machine: x86_64
clock source: unix
detected number of CPU cores: 2
current working directory: /var/django/it/imagetagger/imagetagger
detected binary path: /var/python3/venv/it/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 256541
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /var/run/django/it.sock fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.7.3 (default, Jan 22 2021, 20:04:44)  [GCC 8.3.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x55638a1b2fc0
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72904 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
Traceback (most recent call last):
  File "./imagetagger/wsgi.py", line 12, in <module>
    from configurations.wsgi import get_wsgi_application
  File "/var/python3/venv/it/lib/python3.7/site-packages/configurations/wsgi.py", line 3, in <module>
    importer.install()
  File "/var/python3/venv/it/lib/python3.7/site-packages/configurations/importer.py", line 49, in install
    importer = ConfigurationImporter(check_options=check_options)
  File "/var/python3/venv/it/lib/python3.7/site-packages/configurations/importer.py", line 68, in __init__
    self.validate()
  File "/var/python3/venv/it/lib/python3.7/site-packages/configurations/importer.py", line 113, in validate
    raise ImproperlyConfigured(self.error_msg.format(self.modvar))
django.core.exceptions.ImproperlyConfigured: Configuration cannot be imported, environment variable DJANGO_SETTINGS_MODULE is undefined.
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 27548, cores: 1)

After the browser gave me an Internal Server Error and the terminal says no python application found:

--- no python application found, check your startup logs for errors ---
[pid: 27548|app: -1|req: -1/1] 192.168.178.116 () {40 vars in 655 bytes} [Thu Jul 29 10:46:38 2021] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)

Variables I exported:

export IT_DB_PASSWORD
export DJANGO_CONFIGURATION
export IT_ALLOWED_HOSTS
export IT_DB_HOST
export IT_DOWNLOAD_BASE_URL
export IT_EMAIL_HOST
export IT_SECRET_KEY

Is there something I have to do in regards of missing variable DJANGO_SETTINGS_MODULE?

ImageTagger in general does work with the following commands (Variables are exported):

source /var/python3/venv/it/bin/activate
cd /var/django/it/imagetagger/imagetagger
 ./manage.py runserver 0.0.0.0:8000

Output after an request in the Browser:

django-configurations version , using configuration Prod
Performing system checks...

System check identified no issues (0 silenced).
August 02, 2021 - 15:05:19
Django version 2.2.24, using settings 'imagetagger.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
[02/Aug/2021 15:05:22] "GET /user/login/?next=/images/ HTTP/1.1" 200 3804
[02/Aug/2021 15:05:22] "GET /static/css/bootstrap.min.css HTTP/1.1" 404 77
[02/Aug/2021 15:05:22] "GET /static/css/styles.css HTTP/1.1" 404 77
[02/Aug/2021 15:05:22] "GET /static/scripts/jquery-3.2.1.min.js HTTP/1.1" 404 77
[02/Aug/2021 15:05:22] "GET /static/scripts/bootstrap.min.js HTTP/1.1" 404 77
[02/Aug/2021 15:05:22] "GET /static/symbols/bitbots-logo.png HTTP/1.1" 404 77
[02/Aug/2021 15:05:22] "GET /static/scripts/bootstrap.min.js HTTP/1.1" 404 77
[02/Aug/2021 15:05:22] "GET /static/symbols/bitbots-fav.ico HTTP/1.1" 404 77

Where does the issue occur?

If it is a self hosted instance, please provide further information

  • Operating System: Debian 10.10
  • Python version: 3.7.3
  • UWSGI version: 2.0.19.1
  • ImageTagger commit or version: e007d10
  • Further setup information or configuration files
@timonegk
Copy link
Member

timonegk commented Sep 5, 2021

Does it work if you set the environment variable DJANGO_SETTINGS_MODULE to imagetagger.settings?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants