Skip to content

Commit

Permalink
Rename offspot service unit name
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit74 committed Mar 22, 2024
1 parent 77806c9 commit 9d25d65
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/offspot_demo/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
DOCKER_COMPOSE_MAINT_PATH = SRC_PATH / "maint-compose" / "docker-compose.yml"
DOCKER_COMPOSE_SYMLINK_PATH = Path("/etc/docker/compose.yaml")

Check warning on line 19 in src/offspot_demo/constants.py

View check run for this annotation

Codecov / codecov/patch

src/offspot_demo/constants.py#L17-L19

Added lines #L17 - L19 were not covered by tests

SYSTEMD_UNIT_NAME = "offspot-demo"
SYSTEMD_UNIT_PATH = Path(f"/etc/systemd/system/{SYSTEMD_UNIT_NAME}.service")
SYSTEMD_OFFSPOT_UNIT_NAME = "demo-offspot"
SYSTEMD_OFFSPOT_UNIT_PATH = Path(

Check warning on line 22 in src/offspot_demo/constants.py

View check run for this annotation

Codecov / codecov/patch

src/offspot_demo/constants.py#L21-L22

Added lines #L21 - L22 were not covered by tests
f"/etc/systemd/system/{SYSTEMD_OFFSPOT_UNIT_NAME}.service"
)

JINJA_ENV = Environment(

Check warning on line 26 in src/offspot_demo/constants.py

View check run for this annotation

Codecov / codecov/patch

src/offspot_demo/constants.py#L26

Added line #L26 was not covered by tests
loader=FileSystemLoader(Path(__file__).parent), autoescape=select_autoescape()
Expand Down
16 changes: 10 additions & 6 deletions src/offspot_demo/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
JINJA_ENV,
SRC_PATH,
STARTUP_DURATION,
SYSTEMD_UNIT_NAME,
SYSTEMD_UNIT_PATH,
SYSTEMD_OFFSPOT_UNIT_NAME,
SYSTEMD_OFFSPOT_UNIT_PATH,
)
from offspot_demo.utils import run_command

Check warning on line 15 in src/offspot_demo/setup.py

View check run for this annotation

Codecov / codecov/patch

src/offspot_demo/setup.py#L15

Added line #L15 was not covered by tests

Expand Down Expand Up @@ -56,7 +56,7 @@ def check_systemd_service(
If check_enabled is True, it also checks that the unit is enabled
"""
status = run_command(

Check warning on line 58 in src/offspot_demo/setup.py

View check run for this annotation

Codecov / codecov/patch

src/offspot_demo/setup.py#L58

Added line #L58 was not covered by tests
["systemctl", "status", "--no-pager", f"{SYSTEMD_UNIT_NAME}.service"],
["systemctl", "status", "--no-pager", f"{SYSTEMD_OFFSPOT_UNIT_NAME}.service"],
ok_return_codes=ok_return_codes,
)
if "Loaded: loaded" not in status.stdout:
Expand Down Expand Up @@ -86,13 +86,15 @@ def setup_systemd_service():
print("Installing systemd unit")
shutil.copyfile(

Check warning on line 87 in src/offspot_demo/setup.py

View check run for this annotation

Codecov / codecov/patch

src/offspot_demo/setup.py#L86-L87

Added lines #L86 - L87 were not covered by tests
SRC_PATH / "systemd-unit/offspot-demo.service",
SYSTEMD_UNIT_PATH,
SYSTEMD_OFFSPOT_UNIT_PATH,
)
print("Checking systemd unit")
check_systemd_service(ok_return_codes=[0, 3])

Check warning on line 92 in src/offspot_demo/setup.py

View check run for this annotation

Codecov / codecov/patch

src/offspot_demo/setup.py#L91-L92

Added lines #L91 - L92 were not covered by tests

print("Starting systemd unit")
run_command(["systemctl", "start", "--no-pager", f"{SYSTEMD_UNIT_NAME}.service"])
run_command(

Check warning on line 95 in src/offspot_demo/setup.py

View check run for this annotation

Codecov / codecov/patch

src/offspot_demo/setup.py#L94-L95

Added lines #L94 - L95 were not covered by tests
["systemctl", "start", "--no-pager", f"{SYSTEMD_OFFSPOT_UNIT_NAME}.service"]
)
check_systemd_service(check_running=True)

Check warning on line 98 in src/offspot_demo/setup.py

View check run for this annotation

Codecov / codecov/patch

src/offspot_demo/setup.py#L98

Added line #L98 was not covered by tests

print(

Check warning on line 100 in src/offspot_demo/setup.py

View check run for this annotation

Codecov / codecov/patch

src/offspot_demo/setup.py#L100

Added line #L100 was not covered by tests
Expand All @@ -105,7 +107,9 @@ def setup_systemd_service():
check_systemd_service(check_running=True)

Check warning on line 107 in src/offspot_demo/setup.py

View check run for this annotation

Codecov / codecov/patch

src/offspot_demo/setup.py#L106-L107

Added lines #L106 - L107 were not covered by tests

print("Enabling systemd unit")
run_command(["systemctl", "enable", "--no-pager", f"{SYSTEMD_UNIT_NAME}.service"])
run_command(

Check warning on line 110 in src/offspot_demo/setup.py

View check run for this annotation

Codecov / codecov/patch

src/offspot_demo/setup.py#L109-L110

Added lines #L109 - L110 were not covered by tests
["systemctl", "enable", "--no-pager", f"{SYSTEMD_OFFSPOT_UNIT_NAME}.service"]
)
check_systemd_service(check_running=True, check_enabled=True)

Check warning on line 113 in src/offspot_demo/setup.py

View check run for this annotation

Codecov / codecov/patch

src/offspot_demo/setup.py#L113

Added line #L113 was not covered by tests


Expand Down

0 comments on commit 9d25d65

Please sign in to comment.