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

Error when executing uds server using apache wsgi #60

Closed
osegarra opened this issue Jan 13, 2021 · 3 comments
Closed

Error when executing uds server using apache wsgi #60

osegarra opened this issue Jan 13, 2021 · 3 comments

Comments

@osegarra
Copy link

Hi,

I'm trying to execute openuds as an apache wsgi module:

[root@server1 conf.modules.d]# cat 10-wsgi-python3.conf
# NOTE: mod_wsgi_python3 can not coexist in the same apache process as
# mod_wsgi (python2).  Only load if mod_wsgi is not already loaded.

<IfModule !wsgi_module>
    LoadModule wsgi_module modules/mod_wsgi_python3.so
</IfModule>

WSGIPythonPath /opt/openuds/server/src
WSGIDaemonProcess uds user=apache group=apache threads=25 python-path=/opt/openuds/server/src
WSGIProcessGroup uds
WSGIScriptAlias / /opt/openuds/server/src/server/wsgi.py
WSGIPythonOptimize 2
WSGILazyInitialization off
WSGIApplicationGroup %{GLOBAL}

<Directory /opt/openuds/server/src/server/>
  <Files wsgi.py>
    Require all granted
  </Files>
</Directory>

Alias /static/ /opt/openuds/server/src/static/

<Directory /opt/openuds/server/src/static>
    Require all granted
</Directory>

[root@server1 conf.modules.d]#

But I get a Error 500:

[root@server1 httpd]# cat error_log
[Wed Jan 13 02:42:19.483940 2021] [suexec:notice] [pid 161:tid 139882963102016] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Jan 13 02:42:19.507220 2021] [lbmethod_heartbeat:notice] [pid 161:tid 139882963102016] AH02282: No slotmem from mod_heartmonitor
[Wed Jan 13 02:42:19.507939 2021] [http2:warn] [pid 161:tid 139882963102016] AH02951: mod_ssl does not seem to be enabled
[Wed Jan 13 02:42:19.576354 2021] [mpm_event:notice] [pid 161:tid 139882963102016] AH00489: Apache/2.4.37 (Oracle Linux) mod_wsgi/4.6.4 Python/3.6 configured -- resuming normal operations
[Wed Jan 13 02:42:19.576397 2021] [core:notice] [pid 161:tid 139882963102016] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Wed Jan 13 02:43:44.963357 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877] mod_wsgi (pid=163): Failed to exec Python script file '/opt/openuds/server/src/server/wsgi.py'.
[Wed Jan 13 02:43:44.963422 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877] mod_wsgi (pid=163): Exception occurred processing WSGI script '/opt/openuds/server/src/server/wsgi.py'.
[Wed Jan 13 02:43:44.965262 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877] Traceback (most recent call last):
[Wed Jan 13 02:43:44.965322 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]   File "/opt/openuds/server/src/server/wsgi.py", line 34, in <module>
[Wed Jan 13 02:43:44.965331 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]     application = get_wsgi_application()
[Wed Jan 13 02:43:44.965339 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]   File "/usr/local/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Wed Jan 13 02:43:44.965345 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]     django.setup(set_prefix=False)
[Wed Jan 13 02:43:44.965355 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]   File "/usr/local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
[Wed Jan 13 02:43:44.965361 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]     apps.populate(settings.INSTALLED_APPS)
[Wed Jan 13 02:43:44.965369 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]   File "/usr/local/lib/python3.6/site-packages/django/apps/registry.py", line 122, in populate
[Wed Jan 13 02:43:44.965374 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]     app_config.ready()
[Wed Jan 13 02:43:44.965382 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]   File "/opt/openuds/server/src/uds/__init__.py", line 78, in ready
[Wed Jan 13 02:43:44.965387 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]     from . import REST  # To make sure REST initializes all what it needs
[Wed Jan 13 02:43:44.965395 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]   File "/opt/openuds/server/src/uds/REST/__init__.py", line 220, in <module>
[Wed Jan 13 02:43:44.965400 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]     Dispatcher.initialize()
[Wed Jan 13 02:43:44.965407 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]   File "/opt/openuds/server/src/uds/REST/__init__.py", line 213, in initialize
[Wed Jan 13 02:43:44.965413 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]     importlib.import_module( __name__ + '.' + package + '.' + name)  # import module
[Wed Jan 13 02:43:44.965420 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]   File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
[Wed Jan 13 02:43:44.965425 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]     return _bootstrap._gcd_import(name[level:], package, level)
[Wed Jan 13 02:43:44.965433 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]   File "/opt/openuds/server/src/uds/REST/methods/reports.py", line 39, in <module>
[Wed Jan 13 02:43:44.965448 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]     from uds import reports
[Wed Jan 13 02:43:44.965456 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]   File "/opt/openuds/server/src/uds/reports/__init__.py", line 49, in <module>
[Wed Jan 13 02:43:44.965462 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]     from uds.core import reports
[Wed Jan 13 02:43:44.965469 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]   File "/opt/openuds/server/src/uds/core/reports/__init__.py", line 33, in <module>
[Wed Jan 13 02:43:44.965475 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]     from .report import Report
[Wed Jan 13 02:43:44.965482 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]   File "/opt/openuds/server/src/uds/core/reports/report.py", line 37, in <module>
[Wed Jan 13 02:43:44.965487 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]     from weasyprint import HTML, CSS, default_url_fetcher
[Wed Jan 13 02:43:44.965495 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]   File "/usr/local/lib/python3.6/site-packages/weasyprint/__init__.py", line 473, in <module>
[Wed Jan 13 02:43:44.965500 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]     from .document import Document, Page  # noqa isort:skip
[Wed Jan 13 02:43:44.965507 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]   File "/usr/local/lib/python3.6/site-packages/weasyprint/document.py", line 23, in <module>
[Wed Jan 13 02:43:44.965513 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]     from .draw import draw_page, stacked
[Wed Jan 13 02:43:44.965520 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]   File "/usr/local/lib/python3.6/site-packages/weasyprint/draw.py", line 16, in <module>
[Wed Jan 13 02:43:44.965525 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]     from .images import SVGImage
[Wed Jan 13 02:43:44.965533 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]   File "/usr/local/lib/python3.6/site-packages/weasyprint/images.py", line 14, in <module>
[Wed Jan 13 02:43:44.965538 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]     import cairosvg.parser
[Wed Jan 13 02:43:44.965545 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]   File "/usr/local/lib/python3.6/site-packages/cairosvg/__init__.py", line 99, in <module>
[Wed Jan 13 02:43:44.965550 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877]     svg2svg.__doc__ = surface.Surface.convert.__doc__.replace(
[Wed Jan 13 02:43:44.965569 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877] AttributeError: 'NoneType' object has no attribute 'replace'
[Wed Jan 13 02:43:45.206417 2021] [wsgi:error] [pid 163:tid 139882615752448] [remote 10.0.0.2:59878] mod_wsgi (pid=163): Failed to exec Python script file '/opt/openuds/server/src/server/wsgi.py'.
[Wed Jan 13 02:43:45.206500 2021] [wsgi:error] [pid 163:tid 139882615752448] [remote 10.0.0.2:59878] mod_wsgi (pid=163): Exception occurred processing WSGI script '/opt/openuds/server/src/server/wsgi.py'.
[Wed Jan 13 02:43:45.206628 2021] [wsgi:error] [pid 163:tid 139882615752448] [remote 10.0.0.2:59878] Traceback (most recent call last):
[Wed Jan 13 02:43:45.206666 2021] [wsgi:error] [pid 163:tid 139882615752448] [remote 10.0.0.2:59878]   File "/opt/openuds/server/src/server/wsgi.py", line 34, in <module>
[Wed Jan 13 02:43:45.206673 2021] [wsgi:error] [pid 163:tid 139882615752448] [remote 10.0.0.2:59878]     application = get_wsgi_application()
[Wed Jan 13 02:43:45.206681 2021] [wsgi:error] [pid 163:tid 139882615752448] [remote 10.0.0.2:59878]   File "/usr/local/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Wed Jan 13 02:43:45.206686 2021] [wsgi:error] [pid 163:tid 139882615752448] [remote 10.0.0.2:59878]     django.setup(set_prefix=False)
[Wed Jan 13 02:43:45.206702 2021] [wsgi:error] [pid 163:tid 139882615752448] [remote 10.0.0.2:59878]   File "/usr/local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
[Wed Jan 13 02:43:45.206707 2021] [wsgi:error] [pid 163:tid 139882615752448] [remote 10.0.0.2:59878]     apps.populate(settings.INSTALLED_APPS)
[Wed Jan 13 02:43:45.206729 2021] [wsgi:error] [pid 163:tid 139882615752448] [remote 10.0.0.2:59878]   File "/usr/local/lib/python3.6/site-packages/django/apps/registry.py", line 83, in populate
[Wed Jan 13 02:43:45.206745 2021] [wsgi:error] [pid 163:tid 139882615752448] [remote 10.0.0.2:59878]     raise RuntimeError("populate() isn't reentrant")
[Wed Jan 13 02:43:45.206776 2021] [wsgi:error] [pid 163:tid 139882615752448] [remote 10.0.0.2:59878] RuntimeError: populate() isn't reentrant

Nothing appear in uds.log file.

Thanks a lot in advance.

@osegarra osegarra changed the title Error when executing uds server by wsgi Error when executing uds server using apache wsgi Jan 13, 2021
@dkmstr
Copy link
Collaborator

dkmstr commented Jan 13, 2021

Hi,
your problem seems to come from "cairo.parser", from here exactly:
[Wed Jan 13 02:43:44.965533 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877] File "/usr/local/lib/python3.6/site-packages/weasyprint/images.py", line 14, in
[Wed Jan 13 02:43:44.965538 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877] import cairosvg.parser
[Wed Jan 13 02:43:44.965545 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877] File "/usr/local/lib/python3.6/site-packages/cairosvg/init.py", line 99, in
[Wed Jan 13 02:43:44.965550 2021] [wsgi:error] [pid 163:tid 139882607359744] [remote 10.0.0.2:59877] svg2svg.doc = surface.Surface.convert.doc.replace(

Seems that something is missing on your cairo installation, and as soon as weasyprint tries to load it, it fails...

Hope this helps :).

Note: try an "import cairo.parser" from ipython for example, to try to get something more. Weasyprint tries to load it, but it cannot... May some library is missing in your platform?

@osegarra
Copy link
Author

Hi,

I have checked cairo and cairosvg and looks they are correctly installed.

[root@server1]# python3
Python 3.6.8 (default, Nov  5 2020, 18:03:20)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5.0.1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cairo
>>> import cairo.parser
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cairo.parser'
>>> cairo.version
'1.16.3'
>>> import cairosvg
>>> import cairosvg.parser
>>> from cairosvg import svg2svg
>>> svg2svg.__doc__="hola"
>>>

>>>
[root@server1]# python3
Python 3.6.8 (default, Nov 5 2020, 18:03:20)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5.0.1)] on linux
Type "help", "copyright", "credits" or "license" for more information.

from cairosvg import surface
from cairosvg import svg2svg
svg2svg.doc=surface.Surface.convert.doc.replace('the format for this class', 'SVG')
print(svg2svg.doc)
Convert an SVG document to SVG.

    Specify the input by passing one of these:

    :param bytestring: The SVG source as a byte-string.
    :param file_obj: A file-like object.
    :param url: A filename.

    Give some options:

    :param dpi: The ratio between 1 inch and 1 pixel.
    :param parent_width: The width of the parent container in pixels.
    :param parent_height: The height of the parent container in pixels.
    :param scale: The ouptut scaling factor.
    :param unsafe: A boolean allowing XML entities and very large files
                   (WARNING: vulnerable to XXE attacks and various DoS).

    Specifiy the output with:

    :param write_to: The filename of file-like object where to write the
                     output. If None or not provided, return a byte string.

    Only ``bytestring`` can be passed as a positional argument, other
    parameters are keyword-only.

The packages installed are slightly different thant the listed in the requirements document:

[root@server1]# pip3 list
Package                 Version
----------------------- ---------
asgiref                 3.3.1
bcrypt                  3.2.0
bitarray                1.6.1
cairocffi               1.2.0
CairoSVG                2.5.1
certifi                 2020.12.5
cffi                    1.14.4
chardet                 4.0.0
cryptography            2.9.2
cssselect2              0.4.1
cycler                  0.10.0
defusedxml              0.6.0
Django                  3.1.5
dnspython               2.1.0
gpg                     1.13.1
html5lib                1.1
idna                    2.10
kiwisolver              1.3.1
lxml                    4.6.2
matplotlib              3.3.3
mod-wsgi                4.6.4
mysqlclient             2.0.3
numpy                   1.19.5
ovirt-engine-sdk-python 4.4.9
paramiko                2.7.2
Pillow                  8.1.0
pip                     20.3.3
ply                     3.9
pyasn1                  0.3.7
pyasn1-modules          0.1.5
pycairo                 1.16.3
pycparser               2.14
pycrypto                2.6.1
pycurl                  7.43.0.2
PyNaCl                  1.4.0
pyOpenSSL               19.1.0
pyparsing               2.4.7
Pyphen                  0.10.0
python-dateutil         2.6.1
python-ldap             3.1.0
python-memcached        1.58
pytz                    2020.5
requests                2.25.1
rpm                     4.14.3
setuptools              39.2.0
six                     1.11.0
sqlparse                0.4.1
tinycss2                1.1.0
urllib3                 1.26.2
WeasyPrint              52.2
webencodings            0.5.1
xml-marshaller          1.0.2

Any help will be welcome.

Thansk a lot in advance
Ó

@dkmstr
Copy link
Collaborator

dkmstr commented Jan 21, 2021

I'ts strange,
Some advices:
1.- We use python 3.7 for all our tests, not python 3.6 (i think there should be no problem with 3.6 anyway, just a comment)
2.- Have you tried to run "python3 manage.py runserver 0:8000" for example, to see if it starts without wsgi?
3.- Do not use "master". Master, as noticed on main page "readme", is always under heavy development, and it's not normally functional. Use the 3.0 branch instead.
4.- I have not tried apache on new 3.x branches, so my help is very limited, sorry :(,

@dkmstr dkmstr closed this as completed Mar 21, 2021
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