Skip to content

Commit 2fe2c4e

Browse files
committed
fix(systemd): Add .service suffix to all systemctl commands
Fixes systemctl enable/disable/start/stop/restart commands to consistently use the .service suffix for both concourse-server and concourse-worker. This resolves a compatibility issue with systemd 255 on Ubuntu 24.04 where systemctl enable without the .service suffix can fail with exit code 1. The error was: Status check failed: Command '['systemctl', 'enable', 'concourse-server']' returned non-zero exit status 1. Changed files: - lib/concourse_web.py: Add .service to all systemctl commands - lib/concourse_worker.py: Add .service to all systemctl commands - lib/concourse_helper.py: Add .service to restart/kill commands Fixes: #104 (GitHub Actions CI failure in Deploy step)
1 parent 21b2638 commit 2fe2c4e

File tree

3 files changed

+36
-16
lines changed

3 files changed

+36
-16
lines changed

lib/concourse_helper.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,16 +368,22 @@ def restart_services(self, graceful: bool = True):
368368
try:
369369
if graceful:
370370
# Graceful restart - restart in order
371-
subprocess.run(["systemctl", "restart", "concourse-server"], check=True)
372-
subprocess.run(["systemctl", "restart", "concourse-worker"], check=True)
371+
subprocess.run(
372+
["systemctl", "restart", "concourse-server.service"], check=True
373+
)
374+
subprocess.run(
375+
["systemctl", "restart", "concourse-worker.service"], check=True
376+
)
373377
logger.info("Services restarted gracefully")
374378
else:
375379
# Force restart
376380
subprocess.run(
377-
["systemctl", "kill", "-9", "concourse-server"], capture_output=True
381+
["systemctl", "kill", "-9", "concourse-server.service"],
382+
capture_output=True,
378383
)
379384
subprocess.run(
380-
["systemctl", "kill", "-9", "concourse-worker"], capture_output=True
385+
["systemctl", "kill", "-9", "concourse-worker.service"],
386+
capture_output=True,
381387
)
382388
self.start_services()
383389
logger.info("Services force restarted")

lib/concourse_web.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,12 @@ def _write_config(self, config: dict):
272272
def start_service(self):
273273
"""Start Concourse web server service"""
274274
try:
275-
subprocess.run(["systemctl", "enable", "concourse-server"], check=True)
276-
subprocess.run(["systemctl", "start", "concourse-server"], check=True)
275+
subprocess.run(
276+
["systemctl", "enable", "concourse-server.service"], check=True
277+
)
278+
subprocess.run(
279+
["systemctl", "start", "concourse-server.service"], check=True
280+
)
277281
logger.info("Web server service started")
278282
except subprocess.CalledProcessError as e:
279283
logger.error(f"Failed to start web server: {e}")
@@ -283,10 +287,11 @@ def stop_service(self):
283287
"""Stop Concourse web server service"""
284288
try:
285289
subprocess.run(
286-
["systemctl", "stop", "concourse-server"], capture_output=True
290+
["systemctl", "stop", "concourse-server.service"], capture_output=True
287291
)
288292
subprocess.run(
289-
["systemctl", "disable", "concourse-server"], capture_output=True
293+
["systemctl", "disable", "concourse-server.service"],
294+
capture_output=True,
290295
)
291296
logger.info("Web server service stopped")
292297
except subprocess.CalledProcessError as e:
@@ -295,7 +300,9 @@ def stop_service(self):
295300
def restart_service(self):
296301
"""Restart Concourse web server service"""
297302
try:
298-
subprocess.run(["systemctl", "restart", "concourse-server"], check=True)
303+
subprocess.run(
304+
["systemctl", "restart", "concourse-server.service"], check=True
305+
)
299306
logger.info("Web server service restarted")
300307
except subprocess.CalledProcessError as e:
301308
logger.error(f"Failed to restart web server: {e}")
@@ -305,7 +312,7 @@ def is_running(self) -> bool:
305312
"""Check if web server is running"""
306313
try:
307314
result = subprocess.run(
308-
["systemctl", "is-active", "concourse-server"],
315+
["systemctl", "is-active", "concourse-server.service"],
309316
capture_output=True,
310317
text=True,
311318
)

lib/concourse_worker.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,8 +1085,12 @@ def install_folder_mount_wrapper(self):
10851085
def start_service(self):
10861086
"""Start Concourse worker service"""
10871087
try:
1088-
subprocess.run(["systemctl", "enable", "concourse-worker"], check=True)
1089-
subprocess.run(["systemctl", "start", "concourse-worker"], check=True)
1088+
subprocess.run(
1089+
["systemctl", "enable", "concourse-worker.service"], check=True
1090+
)
1091+
subprocess.run(
1092+
["systemctl", "start", "concourse-worker.service"], check=True
1093+
)
10901094
logger.info("Worker service started")
10911095
except subprocess.CalledProcessError as e:
10921096
logger.error(f"Failed to start worker: {e}")
@@ -1096,10 +1100,11 @@ def stop_service(self):
10961100
"""Stop Concourse worker service"""
10971101
try:
10981102
subprocess.run(
1099-
["systemctl", "stop", "concourse-worker"], capture_output=True
1103+
["systemctl", "stop", "concourse-worker.service"], capture_output=True
11001104
)
11011105
subprocess.run(
1102-
["systemctl", "disable", "concourse-worker"], capture_output=True
1106+
["systemctl", "disable", "concourse-worker.service"],
1107+
capture_output=True,
11031108
)
11041109
logger.info("Worker service stopped")
11051110
except subprocess.CalledProcessError as e:
@@ -1108,7 +1113,9 @@ def stop_service(self):
11081113
def restart_service(self):
11091114
"""Restart Concourse worker service"""
11101115
try:
1111-
subprocess.run(["systemctl", "restart", "concourse-worker"], check=True)
1116+
subprocess.run(
1117+
["systemctl", "restart", "concourse-worker.service"], check=True
1118+
)
11121119
logger.info("Worker service restarted")
11131120
except subprocess.CalledProcessError as e:
11141121
logger.error(f"Failed to restart worker: {e}")
@@ -1118,7 +1125,7 @@ def is_running(self) -> bool:
11181125
"""Check if worker is running"""
11191126
try:
11201127
result = subprocess.run(
1121-
["systemctl", "is-active", "concourse-worker"],
1128+
["systemctl", "is-active", "concourse-worker.service"],
11221129
capture_output=True,
11231130
text=True,
11241131
)

0 commit comments

Comments
 (0)