graphite-project / graphite-web

A highly scalable real-time graphing system
http://graphite.readthedocs.org/
Apache License 2.0
5.87k stars 1.26k forks source link

[BUG] Could not import graphite.local_settings, using defaults! #2811

Closed ichilton closed 11 months ago

ichilton commented 1 year ago

Describe the bug

I'm unable to get graphite-web to find local_settings.py. It's supposed to use: /etc/graphite/local_settings.py and /usr/lib/python3/dist-packages/graphite/settings.py does contain:

# Debian add etc/graphite into path
sys.path.append('/etc/graphite')

... but it's just unable to find it.

root@graphite:~# gunicorn graphite.wsgi --pythonpath=/usr/share/graphite-web --bind 127.0.0.1:8080
[2023-03-23 13:04:57 +0000] [466885] [INFO] Starting gunicorn 20.1.0
[2023-03-23 13:04:57 +0000] [466885] [INFO] Listening at: http://127.0.0.1:8080 (466885)
[2023-03-23 13:04:57 +0000] [466885] [INFO] Using worker: sync
[2023-03-23 13:04:57 +0000] [466886] [INFO] Booting worker with pid: 466886
Could not import graphite.local_settings, using defaults!
/usr/lib/python3/dist-packages/graphite/settings.py:359: UserWarning: SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better security
  warn('SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better security')

I've spent a few hours poking around trying to work out why, but i've not as yet been able to get to the bottom of it.

It just seems not to be looking for it in the right place. It gives that warning whether it's there or not, i've tried dropping the example one in and just changing SECRET_KEY and tried putting symlinks in all kinds of paths where it might go looking for it, but nothing.

To Reproduce

Expected behavior

It should read /etc/graphite/local_settings.py and set the SECRET_KEY.

Environment (please complete the following information):

root@graphite:~# dpkg -l |grep graphite
ii  graphite-carbon                1.1.7-1                        all          backend data caching and persistence daemon for Graphite
ii  graphite-web                   1.1.8-1.1~bpo11+1              all          Enterprise Scalable Realtime Graphing

python3 3.9.2-3 python3-django 2:2.2.28-1~deb11u1

OS packages.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

and1bm commented 1 year ago

I guess this is related to https://bugs.debian.org/995461 where a fix is suggested: os.environ.setdefault('GRAPHITE_SETTINGS_MODULE', 'local_settings') For me, this works so far.