unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.46k stars 691 forks source link

CGI, no app loaded, GAME OVER #2340

Open retifrav opened 3 years ago

retifrav commented 3 years ago

Latest master revision (2989143935775a21d6e8d30c7166c473bd1f78bd) doesn't seem to work in CGI mode. At the same time, 2.0.19.1 version works fine. I tried both versions with the same config, and both versions are built the same way.

The fact that 2.0.19.1 version works makes me think that there might have been some changes since then, but I couldn't figure out what exactly has changed, so I suspect this is a bug.

Environment

$ lsb_release -a
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:    20.04
Codename:   focal

$ python --version
Python 3.8.10

uWSGI config

[uwsgi]
plugin-dir = /tmp/uwsgi
plugins = python,cgi
cgi = /var/www/html/cgi-bin
cgi-allowed-ext = .py
cgi-helper = .py=python

master = true
processes = 5
threads = 10

socket = wsgi.sock
chmod-socket = 664
vacuum = true

Building

2.0.19.1

$ cd /tmp
$ git clone --depth 1 --branch 2.0.19.1 git@github.com:unbit/uwsgi.git
$ cd uwsgi
$ python uwsgiconfig.py --build core
$ python uwsgiconfig.py --plugin plugins/python core
$ python uwsgiconfig.py --plugin plugins/cgi core

master

$ cd /tmp
$ git clone --depth 1 git@github.com:unbit/uwsgi.git
$ cd uwsgi
$ python uwsgiconfig.py --build core
$ python uwsgiconfig.py --plugin plugins/python core
$ python uwsgiconfig.py --plugin plugins/cgi core

Launching

2.0.19.1

$ /tmp/uwsgi/uwsgi --ini ./uwsgi.ini

It outputs the following and runs fine:

[uWSGI] getting INI configuration from ./uwsgi.ini
*** Starting uWSGI 2.0.19.1 (64bit) on [Wed Aug  4 20:52:53 2021] ***
compiled with version: 9.3.0 on 04 August 2021 18:45:43
os: Linux-5.4.0-80-generic #90-Ubuntu SMP Fri Jul 9 22:49:44 UTC 2021
nodename: kubuntu2004vm
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /var/www/html/cgi-bin
detected binary path: /tmp/uwsgi/uwsgi
your processes number limit is 15371
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 wsgi.sock fd 3
Python version: 3.8.10 (default, Jun  2 2021, 10:49:15)  [GCC 9.4.0]
Python main interpreter initialized at 0x560dd7ea68b0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 1002144 bytes (978 KB) for 50 cores
*** Operational MODE: preforking+threaded ***
initialized CGI path: /var/www/html/cgi-bin
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 3846)
spawned uWSGI worker 1 (pid: 3847, cores: 10)
spawned uWSGI worker 2 (pid: 3848, cores: 10)
spawned uWSGI worker 3 (pid: 3849, cores: 10)
spawned uWSGI worker 4 (pid: 3850, cores: 10)
spawned uWSGI worker 5 (pid: 3851, cores: 10)

master

$ /tmp/uwsgi/uwsgi --ini ./uwsgi.ini

It outputs the following and exits with 22 code:

[uWSGI] getting INI configuration from ./uwsgi.ini
*** Starting uWSGI 2.1-dev-2989143 (64bit) on [Wed Aug  4 20:52:00 2021] ***
compiled with version: 9.3.0 on 04 August 2021 18:50:30
os: Linux-5.4.0-80-generic #90-Ubuntu SMP Fri Jul 9 22:49:44 UTC 2021
nodename: kubuntu2004vm
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /var/www/html/cgi-bin
detected binary path: /tmp/uwsgi/uwsgi
dropping root privileges as early as possible
your processes number limit is 15371
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 wsgi.sock fd 3
dropping root privileges after socket binding
Python version: 3.8.10 (default, Jun  2 2021, 10:49:15)  [GCC 9.4.0]
Python main interpreter initialized at 0x561b9c8f2920
dropping root privileges after plugin initialization
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
your request buffer size is 4096 bytes
mapped 1004544 bytes (981 KB) for 50 cores
*** Operational MODE: preforking+threaded ***
initialized CGI path: /var/www/html/cgi-bin
*** no app loaded. GAME OVER ***
VACUUM: unix socket wsgi.sock removed.

It's as if I tried to launch it with --need-app parameter, but it's not there, as you can see.

fukanchik commented 2 years ago

@retifrav were you able to solve this?

retifrav commented 2 years ago

Hm, I don’t quite remember, but as I recall I got this problem with the latest master, so what I did is I took the latest stable/released version instead. So this bug (if it is a bug) is likely still present in master.

I also wrote an article about uWSGI and NGINX, perhaps you’ll find something useful there.

fukanchik commented 2 years ago

Thanks, yes, I also downgraded to 2.0.20 and it worked with no problem.

I would like to know how to work with the latest code though.

niol commented 6 months ago

Duplicate of #2106 , solution is a config file with need-app = False