summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2015-05-21 13:22:19 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2015-05-21 13:22:19 +0200
commitd4b4da584b1912e43ff4a7269fbc93e9676f6df8 (patch)
treeb4de704f218ec51bf633535e48c0c4851557af70 /pykolab
parent44db93b6c3bd4f93916d39e8a29e073368d1edc0 (diff)
downloadpykolab-d4b4da584b1912e43ff4a7269fbc93e9676f6df8.tar.gz
Wait for at most 30 seconds when MySQL/MariaDB is being set up.
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/setup/setup_mysql.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/pykolab/setup/setup_mysql.py b/pykolab/setup/setup_mysql.py
index 460a4d5..c262803 100644
--- a/pykolab/setup/setup_mysql.py
+++ b/pykolab/setup/setup_mysql.py
@@ -20,6 +20,7 @@
import os
import subprocess
import tempfile
+import time
import components
@@ -49,6 +50,14 @@ def description():
return _("Setup MySQL.")
def execute(*args, **kw):
+
+ socket_paths = [
+ "/var/lib/mysql/mysql.sock",
+ "/var/run/mysqld/mysqld.sock",
+ "/var/run/mysql/mysql.sock",
+ "/var/run/mysqld/mysqld.pid"
+ ]
+
# on CentOS7, there is MariaDB instead of MySQL
mysqlservice = 'mysqld.service'
if os.path.isfile('/usr/lib/systemd/system/mariadb.service'):
@@ -73,16 +82,24 @@ def execute(*args, **kw):
log.error(_("Could not configure to start on boot, the " + \
"MySQL database service."))
+ log.info(_("Waiting for at most 30 seconds for MySQL/MariaDB to settle..."))
+ max_wait = 30
+ while max_wait > 0:
+ for socket_path in socket_paths:
+ if os.path.exists(socket_path):
+ max_wait = 0
+
+ if max_wait > 0:
+ max_wait = max_wait - 1
+ time.sleep(1)
+
options = {
1: "Existing MySQL server (with root password already set).",
2: "New MySQL server (needs to be initialized)."
}
answer = 0
- if os.path.exists('/var/lib/mysql/mysql.sock') or \
- os.path.exists('/var/run/mysqld/mysqld.sock') or \
- os.path.exists('/var/run/mysql/mysql.sock') or \
- os.path.exists('/var/run/mysqld/mysqld.pid'):
+ if len([x for x in socket_paths if os.path.exists(x)]) > 0:
if conf.mysqlserver:
if conf.mysqlserver == 'existing':
answer = 1