summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrei Pavel <andrei@isc.org>2024-08-22 09:23:46 +0200
committerAndrei Pavel <andrei@isc.org>2024-08-22 09:23:46 +0200
commita08efdbafb76832bc31fe23d490ab45aae03f34e (patch)
tree729200b545ec14c2219448b625307dc988964f32
parent[#3502] Added a ChangeLog entry (diff)
downloadkea-a08efdbafb76832bc31fe23d490ab45aae03f34e.tar.xz
kea-a08efdbafb76832bc31fe23d490ab45aae03f34e.zip
[#3547] hammer.py: wait for start-stop-daemon/mysqld_safe to exit
Attempt to fix `start-stop-daemon: /usr/bin/mysqld_safe is already running`
-rwxr-xr-xhammer.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/hammer.py b/hammer.py
index 4838ecda12..aa344e00e8 100755
--- a/hammer.py
+++ b/hammer.py
@@ -426,6 +426,15 @@ def execute(cmd, timeout=60, cwd=None, env=None, raise_error=True, dry_run=False
return exitcode
+def wait_for_process_to_exit(process_name):
+ for _ in range(100):
+ exit_code = execute(f'sudo pidof {process_name}', raise_error=False)
+ if exit_code != 0:
+ # Process exited or there was no process to begin with.
+ break
+ time.sleep(1)
+
+
def _append_to_file(file_name, line):
with open(file_name, encoding='utf-8', mode='a') as f:
f.write(line + '\n')
@@ -1371,7 +1380,9 @@ ssl_key = {cert_dir}/kea-client.key
execute('sudo sed -i "/^skip-networking$/d" /etc/my.cnf.d/mariadb-server.cnf')
execute('sudo rc-update add mariadb')
execute('sudo rc-service mariadb stop')
+ wait_for_process_to_exit('start-stop-daemon') # mysqld_safe
execute('sudo rc-service mariadb setup')
+ wait_for_process_to_exit('start-stop-daemon') # mysqld_safe
execute('sudo rc-service mariadb restart')
cmd = "echo 'DROP DATABASE IF EXISTS keatest;' | sudo mysql -u root"