Simple reproducible example:
- project structure:
.
├── app.ini
├── app.py
├── uwsgi.ini
└── wsgi_run.py
app.ini
[app:main]
use = call:app:main
pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
pyramid.debug_routematch = false
pyramid.includes =
app.py
from pyramid.config import Configurator
from pyramid.httpexceptions import HTTPOk
from pyramid.view import view_config
@view_config(route_name='test')
def http_redirect(context, request):
return HTTPOk()
def main(_, **settings):
config = Configurator(settings=settings)
config.add_route('test', '/test')
# Error
1/0
return config.make_wsgi_app()
uwsgi.ini
[uwsgi]
http = 0.0.0.0:9090
master = true
processes = 1
gevent = 8
listen = 4096
buffer-size = 65535
uid = %u
gid = %g
; emperor = 1 does not work too
lazy = true
lazy-app = false
need-app = true
module = wsgi_run
die-on-term = true
sharedarea = 1
ignore-signpipe = true
harakiri-verbose = true
memory-report = true
log-master = true
wsgi_run.py
from pyramid.paster import get_app
application = get_app("app.ini", 'main')
Command to start server:
uwsgi uwsgi.ini
Problem:
When I start server it is retrying to load app in endless loop:
[uWSGI] getting INI configuration from uwsgi.ini
*** Starting uWSGI 2.0.15 (64bit) on [Thu Nov 2 19:17:55 2023] ***
compiled with version: Apple LLVM 15.0.0 (clang-1500.0.40.1) on 16 October 2023 10:59:16
os: Darwin-23.0.0 Darwin Kernel Version 23.0.0: Fri Sep 15 14:42:42 PDT 2023; root:xnu-10002.1.13~1/RELEASE_X86_64
...
your processes number limit is 2784
your memory page size is 4096 bytes
detected max file descriptor number: 256
- async cores set to 8 - fd table size: 256
lock engine: OSX spinlocks
thunder lock: disabled (you can enable it with --thunder-lock)
sharedarea 0 created at 0x10850b000 (1 pages, area at 0x10850c000)
uWSGI http bound on 0.0.0.0:9090 fd 7
uwsgi socket 0 bound to TCP address 127.0.0.1:56279 (port auto-assigned) fd 6
...
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 42563)
spawned uWSGI worker 1 (pid: 42586, cores: 8)
spawned uWSGI http 1 (pid: 42587)
Traceback (most recent call last):
...
File "./app.py", line 15, in main
1/0
ZeroDivisionError: integer division or modulo by zero
unable to load app 0 (mountpoint='') (callable not found or import error)
OOPS ! failed loading app in worker 1 (pid 42586) :( trying again...
DAMN ! worker 1 (pid: 42586) died :( trying respawn ...
Respawned uWSGI worker 1 (new pid: 42590)
Traceback (most recent call last):
...
File "./app.py", line 15, in main
1/0
ZeroDivisionError: integer division or modulo by zero
unable to load app 0 (mountpoint='') (callable not found or import error)
OOPS ! failed loading app in worker 1 (pid 42590) :( trying again...
DAMN ! worker 1 (pid: 42590) died :( trying respawn ...
Respawned uWSGI worker 1 (new pid: 42594)
...
How to make uwsgi server stop if application raised exception on load?