Fix backwards incompatibilities with sh 2.0
also set the pod checker alarm to every 2 minutes. ZFS really doesn't like it more often.
This commit is contained in:
parent
2971420a3c
commit
d0d23416d6
|
@ -1,5 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="Black">
|
||||||
|
<option name="sdkName" value="Python 3.11" />
|
||||||
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
|
||||||
<component name="PythonCompatibilityInspectionAdvertiser">
|
<component name="PythonCompatibilityInspectionAdvertiser">
|
||||||
<option name="version" value="3" />
|
<option name="version" value="3" />
|
||||||
|
|
10
main.py
10
main.py
|
@ -11,12 +11,10 @@ from signal import signal, SIGHUP, SIGINT, SIGTERM, setitimer, SIGALRM, ITIMER_R
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import sh
|
import sh
|
||||||
from sh import podman
|
|
||||||
|
|
||||||
SERVICES_BASE_PATH = "/infra/services/"
|
SERVICES_BASE_PATH = "/infra/services/"
|
||||||
|
|
||||||
# noinspection PyCallingNonCallable
|
shlog = sh.bake(_out=sys.stdout, _err=sys.stderr)
|
||||||
shlog = sh(_out=sys.stdout, _err=sys.stderr)
|
|
||||||
sdnotify = sh.Command("systemd-notify")
|
sdnotify = sh.Command("systemd-notify")
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +66,7 @@ class PodKeeper:
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
os.chdir(self.podhome)
|
os.chdir(self.podhome)
|
||||||
if self.replace and podman.pod.exists(self.podname, _ok_code=[0, 1]).exit_code == 0:
|
if self.replace and sh.podman.pod.exists(self.podname, _ok_code=[0, 1], _return_cmd=True).exit_code == 0:
|
||||||
print(f"Replacing existing pod {self.podname}", file=sys.stderr, flush=True)
|
print(f"Replacing existing pod {self.podname}", file=sys.stderr, flush=True)
|
||||||
shlog.podman.pod.stop(self.podname)
|
shlog.podman.pod.stop(self.podname)
|
||||||
shlog.podman.pod.rm("-f", self.podname)
|
shlog.podman.pod.rm("-f", self.podname)
|
||||||
|
@ -118,7 +116,7 @@ class PodKeeper:
|
||||||
|
|
||||||
def check_pod(self):
|
def check_pod(self):
|
||||||
new_timestamp = datetime.utcnow()
|
new_timestamp = datetime.utcnow()
|
||||||
inspect_command = podman.pod.inspect(self.podname)
|
inspect_command = sh.podman.pod.inspect(self.podname, _return_cmd=True)
|
||||||
pod_description = json.loads(inspect_command.stdout)
|
pod_description = json.loads(inspect_command.stdout)
|
||||||
for container in pod_description["Containers"]:
|
for container in pod_description["Containers"]:
|
||||||
if container["State"] != "running":
|
if container["State"] != "running":
|
||||||
|
@ -180,7 +178,7 @@ def main(network, log_driver, log_level, replace, remove, verbose, identifier):
|
||||||
signal(SIGALRM, keeper.check)
|
signal(SIGALRM, keeper.check)
|
||||||
signal(SIGUSR1, keeper.passthrough)
|
signal(SIGUSR1, keeper.passthrough)
|
||||||
signal(SIGUSR2, keeper.passthrough)
|
signal(SIGUSR2, keeper.passthrough)
|
||||||
setitimer(ITIMER_REAL, 4.0, 10.0)
|
setitimer(ITIMER_REAL, 4.0, 120.0)
|
||||||
|
|
||||||
keeper.run()
|
keeper.run()
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
click~=8.1.7
|
click~=8.1.7
|
||||||
sh~=1.14.3
|
sh~=2.0.6
|
||||||
|
|
Loading…
Reference in a new issue