Skip to content

Commit a08efdb

Browse files
committed
[#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`
1 parent 18e9c20 commit a08efdb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

hammer.py

+11
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,15 @@ def execute(cmd, timeout=60, cwd=None, env=None, raise_error=True, dry_run=False
426426
return exitcode
427427

428428

429+
def wait_for_process_to_exit(process_name):
430+
for _ in range(100):
431+
exit_code = execute(f'sudo pidof {process_name}', raise_error=False)
432+
if exit_code != 0:
433+
# Process exited or there was no process to begin with.
434+
break
435+
time.sleep(1)
436+
437+
429438
def _append_to_file(file_name, line):
430439
with open(file_name, encoding='utf-8', mode='a') as f:
431440
f.write(line + '\n')
@@ -1371,7 +1380,9 @@ def _configure_mysql(system, revision, features):
13711380
execute('sudo sed -i "/^skip-networking$/d" /etc/my.cnf.d/mariadb-server.cnf')
13721381
execute('sudo rc-update add mariadb')
13731382
execute('sudo rc-service mariadb stop')
1383+
wait_for_process_to_exit('start-stop-daemon') # mysqld_safe
13741384
execute('sudo rc-service mariadb setup')
1385+
wait_for_process_to_exit('start-stop-daemon') # mysqld_safe
13751386
execute('sudo rc-service mariadb restart')
13761387

13771388
cmd = "echo 'DROP DATABASE IF EXISTS keatest;' | sudo mysql -u root"

0 commit comments

Comments
 (0)