feat: deluge service (#3)
This commit is contained in:
parent
e3e7a60365
commit
d55e2e486b
6 changed files with 87 additions and 1 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,6 @@
|
||||||
spadinaistan.venv
|
spadinaistan.venv
|
||||||
|
|
||||||
|
deluge/config
|
||||||
|
deluge/downloads
|
||||||
**/healthcheck.json
|
**/healthcheck.json
|
||||||
**/config.json
|
**/config.json
|
||||||
|
|
15
deluge/docker-compose.yml
Normal file
15
deluge/docker-compose.yml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
version: "2.1"
|
||||||
|
services:
|
||||||
|
deluge:
|
||||||
|
image: lscr.io/linuxserver/deluge:latest
|
||||||
|
container_name: deluge
|
||||||
|
environment:
|
||||||
|
- TZ=America/Toronto
|
||||||
|
volumes:
|
||||||
|
- ./config:/config
|
||||||
|
- ./downloads:/downloads
|
||||||
|
ports:
|
||||||
|
- 8112:8112
|
||||||
|
- 6881:6881
|
||||||
|
- 6881:6881/udp
|
||||||
|
restart: unless-stopped
|
3
deluge/script/bootstrap
Normal file
3
deluge/script/bootstrap
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
mkdir ./{config,downloads}
|
64
deluge/tasks.py
Normal file
64
deluge/tasks.py
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
import invoke
|
||||||
|
import pathlib
|
||||||
|
import typing
|
||||||
|
import json
|
||||||
|
|
||||||
|
PATH = pathlib.Path(__file__).parent
|
||||||
|
|
||||||
|
|
||||||
|
@invoke.task()
|
||||||
|
def start(ctx):
|
||||||
|
with ctx.cd(PATH):
|
||||||
|
ctx.run("docker-compose up -d")
|
||||||
|
|
||||||
|
|
||||||
|
@invoke.task()
|
||||||
|
def stop(ctx):
|
||||||
|
with ctx.cd(PATH):
|
||||||
|
ctx.run("docker-compose down")
|
||||||
|
|
||||||
|
|
||||||
|
@invoke.task()
|
||||||
|
def restart(ctx):
|
||||||
|
with ctx.cd(PATH):
|
||||||
|
ctx.run("docker-compose restart")
|
||||||
|
|
||||||
|
|
||||||
|
@invoke.task()
|
||||||
|
def healthcheck(ctx, as_json=False):
|
||||||
|
report = {
|
||||||
|
"containers_running": False,
|
||||||
|
}
|
||||||
|
|
||||||
|
with ctx.cd(PATH):
|
||||||
|
healthy = True
|
||||||
|
# Check that the container is running
|
||||||
|
running_containers = (
|
||||||
|
ctx.run("docker-compose ps --services --status running", hide=True)
|
||||||
|
.stdout.strip()
|
||||||
|
.split()
|
||||||
|
)
|
||||||
|
|
||||||
|
if "deluge" in running_containers:
|
||||||
|
print("✅ Deluge container is running!")
|
||||||
|
report["containers_running"] = True
|
||||||
|
else:
|
||||||
|
print("❌ Deluge is not running, use inv deluge.start.")
|
||||||
|
healthy = False
|
||||||
|
|
||||||
|
if healthy:
|
||||||
|
print("✅ Deluge is healthy!")
|
||||||
|
else:
|
||||||
|
print("❌ Deluge has problems")
|
||||||
|
|
||||||
|
if as_json:
|
||||||
|
with open(pathlib.Path(PATH, "healthcheck.json"), "w") as outfile:
|
||||||
|
outfile.write(json.dumps(report))
|
||||||
|
|
||||||
|
|
||||||
|
ns = invoke.Collection("deluge")
|
||||||
|
|
||||||
|
ns.add_task(start)
|
||||||
|
ns.add_task(restart)
|
||||||
|
ns.add_task(stop)
|
||||||
|
ns.add_task(healthcheck)
|
|
@ -120,7 +120,7 @@ def healthcheck(ctx, as_json=False):
|
||||||
print("❌ Plex has problems")
|
print("❌ Plex has problems")
|
||||||
|
|
||||||
if as_json:
|
if as_json:
|
||||||
with open(pathlib.Path(PATH, 'healthcheck.json'), 'w') as outfile:
|
with open(pathlib.Path(PATH, "healthcheck.json"), "w") as outfile:
|
||||||
outfile.write(json.dumps(report))
|
outfile.write(json.dumps(report))
|
||||||
|
|
||||||
|
|
||||||
|
|
2
tasks.py
2
tasks.py
|
@ -1,7 +1,9 @@
|
||||||
import invoke
|
import invoke
|
||||||
|
|
||||||
import plex.tasks
|
import plex.tasks
|
||||||
|
import deluge.tasks
|
||||||
|
|
||||||
ns = invoke.Collection()
|
ns = invoke.Collection()
|
||||||
|
|
||||||
ns.add_collection(plex.tasks.ns)
|
ns.add_collection(plex.tasks.ns)
|
||||||
|
ns.add_collection(deluge.tasks.ns)
|
||||||
|
|
Reference in a new issue