glennicholls / unraid_parity_scripter Goto Github PK
View Code? Open in Web Editor NEWUnraid user script that supports specifying Python functions to call during parity check start/stop stages
License: MIT License
Unraid user script that supports specifying Python functions to call during parity check start/stop stages
License: MIT License
The current code produces the following output:
2023-09-20 11:33:58,559 - INFO - Parity check is stopped but stop functions haven't been run, calling stop functions. (main.py:44)
2023-09-20 11:33:58,559 - INFO - Starting container 'jellystat' (containers.py:15)
2023-09-20 11:33:58,582 - INFO - Starting container 'jellystat' (containers.py:15)
2023-09-20 11:33:58,606 - INFO - Starting container 'jellystat' (containers.py:15)
2023-09-20 11:33:58,629 - INFO - Starting container 'jellystat' (containers.py:15)
Looks to be an issue with lambda in main.py
The config should be able to be specified by CLI or a config file. Things like containers, log format, etc. CLI would take precedence over config.
TOML config using builtin tomllib would be ideal to reduce verbosity, but won't be used since it wasn't introduced until python 3.11.
Using the "alert" notification fails:
root@server:~# /usr/local/emhttp/webGui/scripts/notify -e 'Parity event' -s 'this subject' -d 'short description' -i alert -m 'some message'
ssmtp: Authorization failed (535 5.7.8 https://support.google.com/mail/?p=BadCredentials f12-20020a02cacc000000b0041ac54cbc60sm505123jap.56 - gsmtp)
root@server:~# /usr/local/emhttp/webGui/scripts/notify
notify [-e "event"] [-s "subject"] [-d "description"] [-i "normal|warning|alert"] [-m "message"] [-x] [-t] [-b] [add]
create a notification
use -e to specify the event
use -s to specify a subject
use -d to specify a short description
use -i to specify the severity
use -m to specify a message (long description)
use -l to specify a link (clicking the notification will take you to that location)
use -x to create a single notification ticket
use -r to specify recipients and not use default
use -t to force send email only (for testing)
use -b to NOT send a browser notification
all options are optional
notify init
Initialize the notification subsystem.
notify smtp-init
Initialize sendmail configuration (ssmtp in our case).
notify get
Output a json-encoded list of all the unread notifications.
notify archive file
Move file from 'unread' state to 'archive' state.
Currently, exceptions can cause the script to exit which is undesireable:
Script Starting Jun 07, 2023 13:16.48
Full logs for this script are available at /tmp/user.scripts/tmpScripts/parity_monitor/log.txt
2023-06-07 13:16:48,530 - INFO - Started monitoring parity state (main.py:55)
2023-06-07 13:16:48,530 - INFO - Checking parity state (main.py:57)
2023-06-07 13:16:48,534 - INFO - Parity check is stopped but stop functions haven't been run, calling stop functions. (monitor.py:102)
2023-06-07 13:16:48,534 - INFO - Starting container 'NginxProxyManager' (containers.py:16)
Traceback (most recent call last):
File "/mnt/user/glen/nas/scripts/unraid_parity_scripter/parity_scripter/main.py", line 68, in
run()
File "/mnt/user/glen/nas/scripts/unraid_parity_scripter/parity_scripter/main.py", line 58, in run
parity_logic(
File "/mnt/user/glen/nas/scripts/unraid_parity_scripter/parity_scripter/monitor.py", line 107, in parity_logic
func()
File "/mnt/user/glen/nas/scripts/unraid_parity_scripter/parity_scripter/main.py", line 61, in
stop_funcs=[lambda: containers.start(args.config)],
File "/mnt/user/glen/nas/scripts/unraid_parity_scripter/parity_scripter/containers.py", line 17, in start
sys_call(f"docker start {container}")
File "/mnt/user/glen/nas/scripts/unraid_parity_scripter/parity_scripter/utils.py", line 36, in sys_call
subprocess.run(shlex.split(command), capture_output=True, check=True)
File "/usr/lib64/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['docker', 'start', 'NginxProxyManager']' returned non-zero exit status 1.
Script Finished Jun 07, 2023 13:16.48
We should catch this and log the traceback.
Jellyfin has some IO heavy scheduled tasks like keyframe, chapter image extraction, etc. Use the API to kill those tasks so the container doesn't need to be stopped.
Add notifications to UI for things like exceptions, errors, etc. https://www.reddit.com/r/unRAID/comments/amxw5f/unraid_notification_after_userscripts_complete/
Configure the logger to write info only to screen and also set up a file logger that logs debug info. The log file should implement a rolling log file so debug doesn't become too big.
On this note, we should also have the script log system info like unraid version, python version, package version etc. for debugging.
Use zipapp to deliver script as a single file to make downloading and running easier.
The release actions are funky since they expect to see a PR with pattern release/v*
, thus creating a PR from an issue branch will not work. Might be worth using tags instead.
A warning/failure notification isn't sent when there is a failure, for example when the docker daemon is down. This script should send a notification to unraid when it experiences an exception so the user is aware that it failed.
The script will start/stop the containers no matter what. Instead, we should query the status of each container to ensure we're not starting a container that is already started.
Capture and log the terminal output. Currently, sys_call sends this to stdout/stderr, but it is not showing up in the unraid log.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.