pannal / Kitana

A responsive Plex plugin web frontend
Other
496 stars 25 forks source link

500 Internal Server Error when using systemd (but not when run manually) #73

Open marc-cwm opened 2 years ago

marc-cwm commented 2 years ago

I'm getting this error when running Kitana via systemd (code at bottom of post) but not when just running Kitana directly from terminal via python3.9 kitana.py . Kitana is running on the same machine as the plex server and no proxy/etc is involved. We are also accessing it from the same local network that Plex is on.

500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last):
  File "/home/<username censored>/.local/lib/python3.9/site-packages/cherrypy/_cprequest.py", line 638, in respond
    self._do_respond(path_info)
  File "/home/<username censored>/.local/lib/python3.9/site-packages/cherrypy/_cprequest.py", line 697, in _do_respond
    response.body = self.handler()
  File "/home/<username censored>/.local/lib/python3.9/site-packages/cherrypy/lib/encoding.py", line 223, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/home/<username censored>/.local/lib/python3.9/site-packages/cherrypy/_cpdispatch.py", line 54, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/opt/Kitana/kitana.py", line 564, in get_plex_token
    return template.render(plex_headers_json=json.dumps(self.plex_headers), **self.default_context)
  File "/home/<username censored>/.local/lib/python3.9/site-packages/jinja2/environment.py", line 1291, in render
    self.environment.handle_exception()
  File "/home/<username censored>/.local/lib/python3.9/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/opt/Kitana/templates/token.jinja2", line 1, in top-level template code
    {% extends "base.jinja2" %}
  File "/opt/Kitana/templates/base.jinja2", line 16, in top-level template code
    <link rel="stylesheet" href="{{ static("/static/css/main.css") }}"/>
  File "/home/<username censored>/.local/lib/python3.9/site-packages/jinja2/utils.py", line 84, in from_obj
    if hasattr(obj, "jinja_pass_arg"):
jinja2.exceptions.UndefinedError: 'static' is undefined
Powered by [CherryPy 18.6.1](http://www.cherrypy.org/)

Systemd code:

[Unit]
Description=Kitana - Web interface for Plex plug-ins
After=network-online.target

[Service]
ExecStart=/usr/bin/python3.9 /opt/Kitana/kitana.py
GuessMainPID=no
Type=forking
User=<username censored, same username as above>
Group=<groupname same as username>

[Install]
WantedBy=multi-user.target
pannal commented 1 year ago

Feels like the environment of systemd is different to your local shell?

marc-cwm commented 1 year ago

Hey, I appreciate you looking at it,

I tried a few other different distros to see if I could get it going, but after that I kinda forgot about it. Any suggestions on a better way to set this up so that wouldn't be an issue? In an ideal world, what would be the intended method?