luigi311 / JellyPlex-Watched

Sync watched between jellyfin and plex locally
GNU General Public License v3.0
394 stars 22 forks source link

[BUG] Permission denied log.log #73

Closed deepakvinod closed 10 months ago

deepakvinod commented 1 year ago

Describe the bug The container does not work with the error log reporting permission denied to log.log from the function main.py. I tried changing the log file to "/var/log/jellyplex.log" but that had no effect either.

To Reproduce Steps to reproduce the behavior:

  1. Compose file with all the variables on the README.
  2. Try to run the container.

Expected behavior For it to run without problems?

Logs PermissionError: [Errno 13] Permission denied: 'log.log'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/app/main.py", line 11, in

main()

File "/app/src/main.py", line 392, in main

logger(error, log_type=2)

File "/app/src/functions.py", line 30, in logger

file = open(logfile, "a", encoding="utf-8")

Type:

Additional context docker on debian, tried both latest and 4.2 tags.

luigi311 commented 1 year ago

Can you post your compose file without the keys?

deepakvinod commented 1 year ago

Thanks for getting back so quickly. Here is the compose

version: "3"
services:

  jellyplex:
    image: luigi311/jellyplex-watched:latest
    container_name: jellyplex
    hostname: jellyplex
    restart: unless-stopped
    user: 1000:1000
    networks:
      - traefik
    environment:
      - TZ=Europe/UK
      - DRYRUN = "False"
      - DEBUG = "True"
      - DEBUG_LEVEL = "debug"
      - RUN_ONLY_ONCE = "False"
      - SLEEP_DURATION = "3600"
      - LOGFILE = "log.log"
      - USER_MAPPING = {"User":"user"}
      - LIBRARY_MAPPING = {"TV Shows":"Shows","Movies":"Movies"}
      - BLACKLIST_LIBRARY = ""
      - WHITELIST_LIBRARY = ""
      - BLACKLIST_LIBRARY_TYPE = ""
      - WHITELIST_LIBRARY_TYPE = ""
      - BLACKLIST_USERS = ""
      - WHITELIST_USERS = "Users"
      - PLEX_BASEURL = "http://192.168.1.25:32400"
      - PLEX_TOKEN = "xxxxxxxxxxxxxxxxx"
      - JELLYFIN_BASEURL = "http://jfin.local/"
      - JELLYFIN_TOKEN = "xxxxxxxxxxxxxxxxxxxx"
      - SSL_BYPASS = "False"
      - SYNC_FROM_PLEX_TO_JELLYFIN = "True"
      - SYNC_FROM_JELLYFIN_TO_PLEX = "True"
      - SYNC_FROM_PLEX_TO_PLEX = "True"
      - SYNC_FROM_JELLYFIN_TO_JELLYFIN = "True"

networks:
  traefik:
    external: true

Edit: I think I found the culprit. It runs when I comment out user setting in compose. But seems to not work? When I look at the logs, it says DRYRUN=True and gives a bunch of empty lists.

luigi311 commented 1 year ago

I have never tried using user for the docker container so im not actually sure if that works or breaks things in the container so it will have to be something i look into. As for your compose file, i personally dont really use compose file but we had another user use compose file on #59 and theirs worked with a volume/env_file being mapped. Can you try and see if that works?

deepakvinod commented 1 year ago

Thank you! Mounting the env file as a volume has somehow worked :) Curious though that directly specifying the environment variables was not working. It ran for the first time and synced the main user but did not sync two local plex users saying that no plex token was found for them.

luigi311 commented 1 year ago

So i took a look at a docker compose setup to see how to use enviornment instead of mapping and it looks like the syntax is just different than what i expect. I went ahead and added a docker compose template located here https://github.com/luigi311/JellyPlex-Watched/blob/dev/docker-compose.yml

I am able to replicate that user 1000:1000 error though so that still needs to be solved. We also need to make it so the docker container doesnt run as root by default in the container since thats not recommended.

JChris246 commented 1 year ago

The docker compose could also be defined to use the variables from the env file like in this example, saving you from having to mount the env file as a volume or typing the values into the docker compose file itself. It's actually how I've been launching: code

luigi311 commented 10 months ago

I have changed the default logfile location to /tmp/log.log so this shouldnt be an issue anymore.