Can't get Graphite running - RuntimeError: populate() isn't reentrant

Hi. I’ve been following this documentation to setup Graphite. I have Icinga 2 running atm.

When going to http://myicingaserver:8000 I get the following error:

[Mon Feb 04 03:24:06.883375 2019] [wsgi:error] [pid 400] [remote 2x3.xx.xx.2xx:38445] mod_wsgi (pid=400): Target WSGI script '/usr/share/graphite-web/graphite.wsgi' cannot be loaded as Python module.
[Mon Feb 04 03:24:06.883435 2019] [wsgi:error] [pid 400] [remote 2x3.xx.xx.2xx:38445] mod_wsgi (pid=400): Exception occurred processing WSGI script '/usr/share/graphite-web/graphite.wsgi'.
[Mon Feb 04 03:24:06.883471 2019] [wsgi:error] [pid 400] [remote 2x3.xx.xx.2xx:38445] Traceback (most recent call last):
[Mon Feb 04 03:24:06.883505 2019] [wsgi:error] [pid 400] [remote 2x3.xx.xx.2xx:38445]   File "/usr/share/graphite-web/graphite.wsgi", line 14, in <module>
[Mon Feb 04 03:24:06.883589 2019] [wsgi:error] [pid 400] [remote 2x3.xx.xx.2xx:38445]     application = get_wsgi_application()
[Mon Feb 04 03:24:06.883630 2019] [wsgi:error] [pid 400] [remote 2x3.xx.xx.2xx:38445]   File "/usr/lib/python2.7/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Mon Feb 04 03:24:06.883707 2019] [wsgi:error] [pid 400] [remote 2x3.xx.xx.2xx:38445]     django.setup(set_prefix=False)
[Mon Feb 04 03:24:06.883744 2019] [wsgi:error] [pid 400] [remote 2x3.xx.xx.2xx:38445]   File "/usr/lib/python2.7/dist-packages/django/__init__.py", line 27, in setup
[Mon Feb 04 03:24:06.883811 2019] [wsgi:error] [pid 400] [remote 2x3.xx.xx.2xx:38445]     apps.populate(settings.INSTALLED_APPS)
[Mon Feb 04 03:24:06.883846 2019] [wsgi:error] [pid 400] [remote 2x3.xx.xx.2xx:38445]   File "/usr/lib/python2.7/dist-packages/django/apps/registry.py", line 78, in populate
[Mon Feb 04 03:24:06.883912 2019] [wsgi:error] [pid 400] [remote 2x3.xx.xx.2xx:38445]     raise RuntimeError("populate() isn't reentrant")
[Mon Feb 04 03:24:06.883958 2019] [wsgi:error] [pid 400] [remote 2x3.xx.xx.2xx:38445] RuntimeError: populate() isn't reentrant

/etc/icinga2/features-enable/graphite.conf:

object GraphiteWriter "graphite" {
  host = "127.0.0.1"
  port = 2003
  enable_send_thresholds = true
  enable_send_metadata = true
}

/etc/apache2/sites-enabled/graphite.conf:

LoadModule wsgi_module modules/mod_wsgi.so

WSGISocketPrefix /var/run/wsgi

Listen 8000
<VirtualHost *:8000>

    ServerName graphite
    ErrorLog ${APACHE_LOG_DIR}/graphite-web_error.log
    CustomLog ${APACHE_LOG_DIR}/graphite-web_access.log combined

    WSGIDaemonProcess graphite-web processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120
    WSGIProcessGroup graphite-web
    WSGIApplicationGroup %{GLOBAL}
    WSGIImportScript /usr/share/graphite-web/graphite.wsgi process-group=graphite-web application-group=%{GLOBAL}

    WSGIScriptAlias / /usr/share/graphite-web/graphite.wsgi

    Alias /static/ /usr/share/graphite-web/static/

    <Directory /usr/share/graphite-web/static/>
            <IfVersion < 2.4>
                    Order deny,allow
                    Allow from all
            </IfVersion>
            <IfVersion >= 2.4>
                    Require all granted
            </IfVersion>
    </Directory>
</VirtualHost>

What am I missing here?
Thanks!

Hi,

the linked documentation doesn’t describe how to setup Graphite, this only covers the integration into Icinga Web 2.

  • How did you manage to install carbon-cache, whisper and graphite-web?
  • Which distribution and version are you on?

Cheers,
Michael

Sorry for reheating this topic, but I have exactly the same error, and cannot fix myself.

I had working graphite with icinga2, and some day i had Error 500.

My error:

 mod_wsgi (pid=690944): Failed to exec Python script file '/opt/graphite/conf/graphite.wsgi'.
 mod_wsgi (pid=690944): Exception occurred processing WSGI script '/opt/graphite/conf/graphite.wsgi'.
 Traceback (most recent call last):
   File "/opt/graphite/conf/graphite.wsgi", line 3, in <module>
 from graphite.wsgi import application
   File "/usr/lib/python3/dist-packages/graphite/wsgi.py", line 14, in <module>
 application = get_wsgi_application()
   File "/usr/lib/python3/dist-packages/django/core/wsgi.py", line 12, in get_wsgi_application
 django.setup(set_prefix=False)
   File "/usr/lib/python3/dist-packages/django/__init__.py", line 24, in setup
 apps.populate(settings.INSTALLED_APPS)
   File "/usr/lib/python3/dist-packages/django/apps/registry.py", line 83, in populate
 raise RuntimeError("populate() isn't reentrant")
 RuntimeError: populate() isn't reentrant

But when I try to execure this script manually, then no errors returned.

python /opt/graphite/conf/graphite.wsgi

Debian 10, updated.

Hi.

Unfortunately, this is more a generic error message than something helpful.

Sometimes, a simple restart of the Apache helps.

here (external link) you can find additional information.

here (same thread, external link) you find information of how to access additional information to the error (by changing the log-output).

You could also have a look at this amazing guide


Greetings.

Got the same error - check your file permissions of the log files in /opt/graphite/storage/log/webapp, setting these writeable to the apache-user fixed the problem for me

Regards

1 Like