Update project, add verbosity option to podlaunch

Use /infra as base directory instead of /docker
This commit is contained in:
Ben 2023-09-23 00:36:58 +02:00
parent 03dbe75cf1
commit 2971420a3c
Signed by: ben
GPG key ID: 0F54A7ED232D3319
6 changed files with 16 additions and 14 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" 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" />
</component> </component>

View file

@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4"> <module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.10" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="Python 3.11" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>

View file

@ -10,7 +10,7 @@ Type=oneshot
Environment=PODMAN_SYSTEMD_UNIT=%n Environment=PODMAN_SYSTEMD_UNIT=%n
LogExtraFields=IMAGE=%i LogExtraFields=IMAGE=%i
ExecCondition=/usr/bin/bash -c '[[ $(podman images --format json localhost/%i | jq .\\[0\\]) == "null" ]]' ExecCondition=/usr/bin/bash -c '[[ $(podman images --format json localhost/%i | jq .\\[0\\]) == "null" ]]'
Environment="IMAGE_TAG=localhost/%i" "BUILD_SOURCE=/docker/containers/%i" Environment="IMAGE_TAG=localhost/%i" "BUILD_SOURCE=/infra/containers/%i"
ExecStart=/usr/bin/podman build --tag ${IMAGE_TAG} $EXTRAOPTS ${BUILD_SOURCE} ExecStart=/usr/bin/podman build --tag ${IMAGE_TAG} $EXTRAOPTS ${BUILD_SOURCE}
Restart=no Restart=no
RemainAfterExit=no RemainAfterExit=no
@ -18,4 +18,3 @@ TimeoutStartSec=1h
SendSIGKILL=no SendSIGKILL=no
LogRateLimitIntervalSec=15min LogRateLimitIntervalSec=15min
LogRateLimitBurst=1500 LogRateLimitBurst=1500

View file

@ -11,7 +11,7 @@ import sh
from sh import podman from sh import podman
from sh import systemctl from sh import systemctl
SERVICES_BASE_PATH = "/docker/services/" SERVICES_BASE_PATH = "/infra/services/"
def resolve_image_units(): def resolve_image_units():
@ -91,11 +91,8 @@ def resolve_image_units():
@click.option("--verbose", is_flag=True, default=False, help="Enable INFO logging") @click.option("--verbose", is_flag=True, default=False, help="Enable INFO logging")
def main(verbose): def main(verbose):
if verbose: if verbose:
loglevel = logging.INFO logging.root.setLevel(logging.INFO)
else:
loglevel = logging.CRITICAL
logging.basicConfig(level=loglevel)
image_units = resolve_image_units() image_units = resolve_image_units()
image_tags: Set[str] = set() image_tags: Set[str] = set()
@ -172,4 +169,5 @@ def main(verbose):
if __name__ == "__main__": if __name__ == "__main__":
logging.basicConfig(level=logging.ERROR)
main() main()

11
main.py
View file

@ -13,7 +13,7 @@ import click
import sh import sh
from sh import podman from sh import podman
SERVICES_BASE_PATH = "/docker/services/" SERVICES_BASE_PATH = "/infra/services/"
# noinspection PyCallingNonCallable # noinspection PyCallingNonCallable
shlog = sh(_out=sys.stdout, _err=sys.stderr) shlog = sh(_out=sys.stdout, _err=sys.stderr)
@ -157,9 +157,13 @@ class PodKeeper:
@click.option("--replace/--no-replace", default=True, help="Controls replacement of previously running pod with the " @click.option("--replace/--no-replace", default=True, help="Controls replacement of previously running pod with the "
"same name") "same name")
@click.option("--remove/--keep", default=True, help="Controls removal of pod after stopping") @click.option("--remove/--keep", default=True, help="Controls removal of pod after stopping")
@click.option("--verbose", is_flag=True, default=False, help="Enable DEBUG logging")
@click.argument("identifier") @click.argument("identifier")
def main(network, log_driver, log_level, replace, remove, identifier): def main(network, log_driver, log_level, replace, remove, verbose, identifier):
logging.basicConfig(level=logging.INFO) if verbose:
logging.root.setLevel(logging.DEBUG)
else:
logging.root.setLevel(logging.INFO)
keeper = PodKeeper( keeper = PodKeeper(
network=network, network=network,
@ -182,4 +186,5 @@ def main(network, log_driver, log_level, replace, remove, identifier):
if __name__ == '__main__': if __name__ == '__main__':
logging.basicConfig()
main() main()

View file

@ -1,2 +1,2 @@
click~=8.0.1 click~=8.1.7
sh~=1.14.2 sh~=1.14.3