pairofcrocs / qbit-unraid-slowdown

A script that interacts with the Plex server, qBittorrent, and an Unraid server to manage the speed of qBittorrent downloads based on the number of active streams on Plex and the status of a parity check operation on the Unraid server.
11 stars 2 forks source link

[Question] User Script vs Post Arguments #6

Open alex-cardenas opened 11 months ago

alex-cardenas commented 11 months ago

I've been having reliability issues with the Unraid User Scripts plugin scheduling "feature".

Is it possible to add the depencies script to the Tautulli docker container as an extra parameter instead of using a User Script?

alex-cardenas commented 11 months ago

To test, I went to edit the Tautulli container > Advanced View > Post arguments > "pip install requests qbittorrent-api paramiko python-dotenv"

This nearly works. When I start the container, the command does run and the dependencies are installed but then Tautulli stops with this log entry:

2023-11-08 09:17:57 - INFO :: MainThread : Signal 15 caught, saving and exiting...

More research needed.

alex-cardenas commented 11 months ago

Asked official Tautulli Discord support but was told they don't support troubleshooting any issues that modify the Tautulli container. Reddit might be my next stop https://discord.com/channels/183396325142822912/1171843300966277141

pairofcrocs commented 11 months ago

I think I may have a fix sh -c "pip install requests qbittorrent-api paramiko python-dotenv" See if this works for you :)

EDIT: I'm experiencing crashing shortly after the pip install finishes.

alex-cardenas commented 11 months ago

Are you experiencing the Signal 15 shutdown code? I've learned that is the 'normal' shutdown command; not an error of any sort. I'm not sure what's triggering it.

The tautulli dev responded to my support question with:

I will say that typically you can install requirements into the script folder and the script will use them. pip install requests qbittorrent-api paramiko python-dotenv --target=/appdata/Tautulli/scripts

But I was getting an error that I didn't initially understand and also didn't have time to research

Edit: I'm using Linuxserver's version of tautulli

pairofcrocs commented 11 months ago

Are you experiencing the Signal 15 shutdown code? I've learned that is the 'normal' shutdown command; not an error of any sort. I'm not sure what's triggering it.

No, mine is installing everything correctly but then giving me this:

Installing collected packages: urllib3, python-dotenv, packaging, idna, charset-normalizer, certifi, bcrypt, requests, pynacl, qbittorrent-api, paramiko

** Press ANY KEY to close this window ** 

Then the app just shuts down

I'm using the official version of the container

pairofcrocs commented 11 months ago

The other option, defiantly not as 'clean', is running the user script every 5 minutes, so even though it doesn't persist though reboots, it would only ever be down for 5ish minutes.

alex-cardenas commented 11 months ago

Here's my startup log with the following command:

pip install requests qbittorrent-api paramiko python-dotenv

[custom-init]` No custom files found, skipping... 2023-11-08 13:14:54 - INFO :: MainThread : Starting Tautulli v2.13.2 2023-11-08 13:14:54 - INFO :: MainThread : [Docker] Linux 6.1.49-Unraid (#1 SMP PREEMPT_DYNAMIC Wed Aug 30 09:42:35 PDT 2023 - Alpine Linux 3.18.4) 2023-11-08 13:14:54 - INFO :: MainThread : America/Chicago (UTC-0600) 2023-11-08 13:14:54 - INFO :: MainThread : Python 3.11.6 (main, Oct 4 2023, 06:22:18) [GCC 12.2.1 20220924] 2023-11-08 13:14:54 - INFO :: MainThread : SQLite 3.41.2 2023-11-08 13:14:54 - INFO :: MainThread : Program Dir: /app/tautulli 2023-11-08 13:14:54 - INFO :: MainThread : Config File: /config/config.ini 2023-11-08 13:14:54 - INFO :: MainThread : Database File: /config/tautulli.db 2023-11-08 13:14:54 - INFO :: MainThread : Checking if the database upgrades are required... 2023-11-08 13:14:54 - INFO :: MainThread : Checking if configuration upgrades are required... 2023-11-08 13:14:54 - INFO :: Thread-1 (startup_refresh) : Tautulli PlexTV :: Requesting resources for server... 2023-11-08 13:14:54 - INFO :: Thread-1 (startup_refresh) : Tautulli PlexTV :: Pinging Plex.tv to refresh token. 2023-11-08 13:14:54 - INFO :: MainThread : Tautulli NotificationHandler :: Starting background notification handler (2 threads). 2023-11-08 13:14:54 - INFO :: MainThread : Tautulli NewsletterHandler :: Scheduled newsletter: Recently Added (newsletter_id 5) 2023-11-08 13:14:55 - INFO :: MainThread : Tautulli WebStart :: Initializing Tautulli web server... 2023-11-08 13:14:55 - INFO :: MainThread : Tautulli WebStart :: Web server authentication is enabled: Tautulli admin (username is '[redacted]') and Plex admin. 2023-11-08 13:14:55 - INFO :: MainThread : Tautulli WebStart :: Thread Pool Size: 10. 2023-11-08 13:14:55 - INFO :: MainThread : Tautulli WebStart :: Starting Tautulli web server on http://0.0.0.0:8181/ 2023-11-08 13:14:55 - INFO :: MainThread : [08/Nov/2023:13:14:55] ENGINE Serving on http://0.0.0.0:8181 2023-11-08 13:14:55 - INFO :: MainThread : Tautulli is ready! 2023-11-08 13:14:55 - INFO :: Thread-1 (startup_refresh) : Tautulli Config :: Writing configuration to file 2023-11-08 13:14:55 - INFO :: Thread-1 (startup_refresh) : Tautulli PlexTV :: Server URL retrieved. 2023-11-08 13:14:55 - INFO :: Thread-1 (startup_refresh) : Tautulli PlexTV :: Selected server: [redacted] 2023-11-08 13:14:55 - INFO :: Thread-1 (startup_refresh) : Tautulli Config :: Writing configuration to file 2023-11-08 13:14:55 - DEBUG :: Thread-1 (startup_refresh) : Tautulli Monitor :: Checking for active streams. 2023-11-08 13:14:55 - INFO :: Thread-15 (run) : Tautulli WebSocket :: Opening secure websocket. 2023-11-08 13:14:55 - INFO :: Thread-1 (startup_refresh) : Tautulli Users :: Requesting users list refresh... 2023-11-08 13:14:55 - INFO :: Thread-15 (run) : Tautulli WebSocket :: Ready 2023-11-08 13:14:55 - INFO :: Thread-15 (run) : Scheduled background task: Optimize Tautulli database 2023-11-08 13:14:55 - INFO :: Thread-15 (run) : Scheduled background task: Backup Tautulli database 2023-11-08 13:14:55 - INFO :: Thread-15 (run) : Scheduled background task: Backup Tautulli config 2023-11-08 13:14:55 - INFO :: Thread-15 (run) : Scheduled background task: Refresh Plex server URLs 2023-11-08 13:14:55 - INFO :: Thread-15 (run) : Scheduled background task: Refresh users list 2023-11-08 13:14:55 - INFO :: Thread-15 (run) : Scheduled background task: Refresh libraries list [ls.io-init] done. Requirement already satisfied: requests in /lsiopy/lib/python3.11/site-packages (2.31.0) Collecting qbittorrent-api Downloading qbittorrent_api-2023.11.55-py3-none-any.whl.metadata (18 kB) 2023-11-08 13:14:56 - INFO :: Thread-1 (startup_refresh) : Tautulli Users :: Users list refreshed. 2023-11-08 13:14:56 - INFO :: Thread-1 (startup_refresh) : Tautulli Libraries :: Requesting libraries list refresh... Collecting paramiko Downloading paramiko-3.3.1-py3-none-any.whl.metadata (4.4 kB) Collecting python-dotenv Downloading python_dotenv-1.0.0-py3-none-any.whl (19 kB) Requirement already satisfied: charset-normalizer<4,>=2 in /lsiopy/lib/python3.11/site-packages (from requests) (3.3.2) Requirement already satisfied: idna<4,>=2.5 in /lsiopy/lib/python3.11/site-packages (from requests) (3.4) Requirement already satisfied: urllib3<3,>=1.21.1 in /lsiopy/lib/python3.11/site-packages (from requests) (1.26.18) Requirement already satisfied: certifi>=2017.4.17 in /lsiopy/lib/python3.11/site-packages (from requests) (2023.7.22) Requirement already satisfied: packaging in /lsiopy/lib/python3.11/site-packages (from qbittorrent-api) (23.1) Collecting bcrypt>=3.2 (from paramiko) Downloading bcrypt-4.0.1-cp36-abi3-musllinux_1_1_x86_64.whl (624 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 624.3/624.3 kB 7.0 MB/s eta 0:00:00 Requirement already satisfied: cryptography>=3.3 in /lsiopy/lib/python3.11/site-packages (from paramiko) (41.0.5) Collecting pynacl>=1.5 (from paramiko) Downloading PyNaCl-1.5.0-cp36-abi3-musllinux_1_1_x86_64.whl (1.1 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 31.2 MB/s eta 0:00:00 Requirement already satisfied: cffi>=1.12 in /lsiopy/lib/python3.11/site-packages (from cryptography>=3.3->paramiko) (1.16.0) Requirement already satisfied: pycparser in /lsiopy/lib/python3.11/site-packages (from cffi>=1.12->cryptography>=3.3->paramiko) (2.21) Downloading qbittorrent_api-2023.11.55-py3-none-any.whl (59 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 59.3/59.3 kB 3.4 MB/s eta 0:00:00 Downloading paramiko-3.3.1-py3-none-any.whl (224 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 224.8/224.8 kB 12.7 MB/s eta 0:00:00 Installing collected packages: python-dotenv, bcrypt, qbittorrent-api, pynacl, paramiko Successfully installed bcrypt-4.0.1 paramiko-3.3.1 pynacl-1.5.0 python-dotenv-1.0.0 qbittorrent-api-2023.11.55 2023-11-08 13:14:57 - INFO :: Thread-1 (startup_refresh) : Tautulli Config :: Writing configuration to file 2023-11-08 13:14:57 - INFO :: Thread-1 (startup_refresh) : Tautulli Libraries :: Libraries list refreshed. 2023-11-08 13:14:57 - INFO :: MainThread : Signal 15 caught, saving and exiting... 2023-11-08 13:14:57 - INFO :: MainThread : Tautulli WebStart :: Stopping Tautulli web server... 2023-11-08 13:14:57 - INFO :: MainThread : [08/Nov/2023:13:14:57] ENGINE Bus STOPPING 2023-11-08 13:14:58 - INFO :: MainThread : [08/Nov/2023:13:14:58] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8181)) shut down 2023-11-08 13:14:58 - INFO :: MainThread : [08/Nov/2023:13:14:58] ENGINE Bus STOPPED 2023-11-08 13:14:58 - INFO :: MainThread : [08/Nov/2023:13:14:58] ENGINE Bus EXITING 2023-11-08 13:14:58 - INFO :: MainThread : [08/Nov/2023:13:14:58] ENGINE Bus EXITED 2023-11-08 13:14:58 - INFO :: MainThread : Tautulli WebSocket :: Disconnecting websocket... 2023-11-08 13:14:58 - DEBUG :: Thread-15 (run) : Tautulli WebSocket :: Leaving thread. 2023-11-08 13:14:58 - INFO :: MainThread : Tautulli Config :: Writing configuration to file 2023-11-08 13:14:58 - INFO :: Thread-2 (process_queue) : Tautulli NotificationHandler :: Notification thread exiting... 2023-11-08 13:14:58 - INFO :: Thread-3 (process_queue) : Tautulli NotificationHandler :: Notification thread exiting... 2023-11-08 13:14:58 - INFO :: MainThread : Tautulli is shutting down...

pairofcrocs commented 11 months ago

Mine is totally different:

WARNING: The directory '/home/tautulli/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/home/tautulli'
Check the permissions.

[notice] A new release of pip is available: 23.0.1 -> 23.3.1
[notice] To update, run: pip install --upgrade pip
Running Tautulli using user tautulli (uid=99) and group tautulli (gid=100)
Defaulting to user installation because normal site-packages is not writeable
Collecting requests
  Downloading requests-2.31.0-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 kB 1.5 MB/s eta 0:00:00
Collecting qbittorrent-api
  Downloading qbittorrent_api-2023.11.55-py3-none-any.whl (59 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 59.3/59.3 kB 2.7 MB/s eta 0:00:00
Collecting paramiko
  Downloading paramiko-3.3.1-py3-none-any.whl (224 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 224.8/224.8 kB 2.9 MB/s eta 0:00:00
Collecting python-dotenv
  Downloading python_dotenv-1.0.0-py3-none-any.whl (19 kB)
Collecting idna<4,>=2.5
  Downloading idna-3.4-py3-none-any.whl (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 kB 2.4 MB/s eta 0:00:00
Collecting urllib3<3,>=1.21.1
  Downloading urllib3-2.0.7-py3-none-any.whl (124 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 124.2/124.2 kB 1.6 MB/s eta 0:00:00
Collecting charset-normalizer<4,>=2
  Downloading charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 142.3/142.3 kB 3.2 MB/s eta 0:00:00
Collecting certifi>=2017.4.17
  Downloading certifi-2023.7.22-py3-none-any.whl (158 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 158.3/158.3 kB 3.3 MB/s eta 0:00:00
Collecting packaging
  Downloading packaging-23.2-py3-none-any.whl (53 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 53.0/53.0 kB 5.0 MB/s eta 0:00:00
Collecting bcrypt>=3.2
  Downloading bcrypt-4.0.1-cp36-abi3-manylinux_2_28_x86_64.whl (593 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 593.7/593.7 kB 3.1 MB/s eta 0:00:00
Collecting pynacl>=1.5
  Downloading PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (856 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 856.7/856.7 kB 3.2 MB/s eta 0:00:00
Requirement already satisfied: cryptography>=3.3 in /usr/local/lib/python3.9/site-packages (from paramiko) (39.0.2)
Requirement already satisfied: cffi>=1.12 in /usr/local/lib/python3.9/site-packages (from cryptography>=3.3->paramiko) (1.15.1)
Requirement already satisfied: pycparser in /usr/local/lib/python3.9/site-packages (from cffi>=1.12->cryptography>=3.3->paramiko) (2.21)
Installing collected packages: urllib3, python-dotenv, packaging, idna, charset-normalizer, certifi, bcrypt, requests, pynacl, qbittorrent-api, paramiko

** Press ANY KEY to close this window ** 
alex-cardenas commented 11 months ago

That's so weird. Regarding your other suggestion, the reason I went this route is b/c User Script scheduling isn't working for me. When I hit "Apply" after setting any kind of schedule, nothing happens. When I navigate away from the page and back there again, they're all listed as Schedule Disabled

I do think a post argument would be best practice as any sort of restart of the container (or updating the container) would clear the dependencies. User Script only has option for repeating or start of array. I could be wrong.

pairofcrocs commented 11 months ago

I 100% agree that adding a post argument would be best practices.

With user scripts, you can set a custom cron schedule to go off whenever you want.

I'm going to keep looking into this :)

alex-cardenas commented 11 months ago

Same issue with cron schedule - couldn't get it to save. I'll make a post on the User Script forum about that as a potential workaround. And thanks! Lmk if you need a tester; I don't know much but I can push buttons haha

pairofcrocs commented 11 months ago

I'm going to ping @tmarkn and see if he has any suggestions :)