Giter Site home page Giter Site logo

unraid_parity_scripter's People

Watchers

 avatar

unraid_parity_scripter's Issues

Only single container is being stopped/started

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

Allow config to be specified via CLI or config file

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 "alert" notification fails

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.

Catch and log exceptions so script doesn't exit

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.

Use jellyfin api to kill io heavy tasks

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.

Set up rolling log file

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.

Update actions for release

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.

No notification during failures

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.

Log terminal output

Capture and log the terminal output. Currently, sys_call sends this to stdout/stderr, but it is not showing up in the unraid log.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.