Permalink
Browse files

tweak mysql service adapter to perform change password operations mor…

…e gracefully
  • Loading branch information...
1 parent a1ba630 commit 5bcbf11dc27122bcf84ff2005a789d38c1ab2314 @movitto committed Dec 18, 2011
Showing with 6 additions and 3 deletions.
  1. +6 −3 snap/backends/services/adapters/mysql.py
View
9 snap/backends/services/adapters/mysql.py
@@ -120,9 +120,12 @@ def set_root_pass():
dispatcher.stop_service(Mysql.DAEMON)
server = subprocess.Popen([Mysql.MYSQLDSAFE_CMD, '--skip-grant-tables'])
- client = subprocess.Popen([Mysql.MYSQL_CMD, '-u', 'root', '-e', 'update user set password=PASSWORD("' + mysql_password + '") where user="root"; flush privileges;'])
- client.kill()
- server.kill()
+ client = subprocess.Popen([Mysql.MYSQL_CMD, 'mysql', '-u', 'root', '-e', "update user set password=PASSWORD('" + mysql_password + "') where user='root'; flush privileges;"])
+ client.wait()
+ client = subprocess.Popen([Mysql.MYSQLADMIN_CMD, 'shutdown'])
+ client.wait()
+ if server.poll() == None: # race condition?
+ server.kill()
if already_running:
dispatcher.start_service(Mysql.DAEMON)

0 comments on commit 5bcbf11

Please sign in to comment.