Re: Troubleshooting wsgi file
"John P. Rouillard" <[email protected]>
| Newsgroups | gmane.comp.bug-tracking.roundup.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Tom:
In message
<CO3PR08MB79571305214FAFBC68F80EE0CA879@CO3PR08MB7957.namprd08.prod.
outlook.com>, Tom Ekberg writes:
>On an Ubuntu 22.04 host I'm running apache 2.4.52 with python 3.10,
>using roundup 2.1 to execute a wsgi.py file.
So the environment is apache with mod_wsgi. Are you using daemon mode?
What does your apache config look like?
Also it looks like Roundup is installed into a virtualenv.
>After running it (bringing up the URL in a browser) the apache error.log says:
>
>[Mon Jul 11 08:53:50.070418 2022] [wsgi:error] [pid 60096:tid 139981150303808] [remote 10.67.80.23:64993] mod_wsgi (pid=60096): Exception occurred processing WSGI script '/mnt/trackers/it_test/apache/wsgi.py'.
>[Mon Jul 11 08:53:50.070531 2022] [wsgi:error] [pid 60096:tid 139981150303808] [remote 10.67.80.23:64993] RuntimeError: response has not been started
>
> [...] Nothing is written to /tmp/wsgi.log.
>
>I can run the wsgi.py file from the command line and it works fine.
>It also writes to /tmp/wsgi.log.
Have you tried writing to (and flushing) the write to /tmp/wsgi.log as
the first line in your wsgi wrapper? If so, then it sounds like it's
not even invoking the wsgi.py wrapper properly.
I have used gunicorn and uwsgi with Roundup installed in the system
tree. I don't use apache so I am a bit stumped.
Are you sure that mod_wsgi is working? Maybe try a simple hello world
app like:
https://www.shellhacks.com/modwsgi-hello-world-example/
to make sure that it's not a wsgi config issue before roundup starts.
Alternatively try the script in he installation.txt doc at line 1199:
https://sourceforge.net/p/roundup/code/ci/default/tree/doc/installation.txt#l1199
and set enabled=False.
Also
https://modwsgi.readthedocs.io/en/develop/user-guides/debugging-techniques.html
and/or
http://blog.dscpl.com.au/2014/09/debugging-with-pdb-when-using-modwsgi.html
may help.
>>>> import wsgi
>>>> wsgi.app
><roundup.cgi.wsgi_handler.RequestDispatcher object at 0x7f76ae028be0>
>>>> d = dict(PATH_INFO='/', REQUEST_METHOD='GET')
>>>> d['wsgi.input'] = ''
>>>> >>> wsgi.application(d, '')
>[]
I'm not sure what this proves. I expect I would get some output and
not [] if things were working right.
>There are differences between my wsgi.py (attached, see below) and
>Roundup's frontends/wsgi.py, mostly so I could add debugging
>statements and change sys.path.
Understood.
>I made sure the sys.path directories
>mentioned in my wsgi.py exist. This one is for roundup:
>$ ls -dl /usr/local/share/virtualenvs/tracker-env/lib/python3.10/site-packages/roundup
>[...]>
>The other sys.path change is for xapian:
>
>$ ls -dl /usr/lib/python3/dist-packages/xapian/
>[...]
Can you do that? Mix packages from a system installed and a virtualenv
installed environment? I see how you are arranging the order to have
the venv consulted first. But maybe try without the system paths (and
xapian) to start and see if that results in something different.
>I cut/pasted these paths from the attached wsgi.py file. The wsgi.py
>ownership and group is roundup, and the mode is 744.
Just out of curiosity should it be 755? It will be apache running the
wsgi right? Is apache running as roundup? Does wsgi.py need to be
executable? Neither uwsgi nor gnuicorn required execution rights.
>----- attachment -----
>import sys
># Fix sys.path to contain the VENV path.
># The apt package python3-xapian put the xapian python package in python3.
># Put this path last so it only sees the xapian package.
>for new_path in ['/usr/local/share/virtualenvs/tracker-env/lib/python3.10/site-packages',
> '/usr/lib/python3/dist-packages']:
> if new_path not in sys.path:
> sys.path.append(new_path)
>
>from roundup.cgi.wsgi_handler import RequestDispatcher
>tracker_home = '/mnt/trackers/it_test'
>app = RequestDispatcher(tracker_home)
Except for mixing venv and system paths, I am with you up to here.
>debug = True
># Store the environment into a log file.
>
>from datetime import datetime
>def debug_log(message):
> with open('/tmp/wsgi.log', 'a') as log:
> now = datetime.now()
> log.write('{now} {message}\n'.format(**locals()))
>
>def application(environ, start_response):
> """
> The main WSGI application.
> """
> if debug:
> debug_log(environ)
> debug_log(sys.path)
> return app(environ, start_response)
I don't understand why application() is needed.
Did you try running the wsgi.py file that ended with:
app = ....
and get an error so you added the application wrapper for debugging?
Have a great afternoon.
--
-- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.