Commit 4d86898a authored by Łukasz Nowak's avatar Łukasz Nowak

- change behavoiour and do *NOT* call mysql_install unconditionally

Unfortunately mysql_install dies in case if there is software upgrade.
And from current knowledge the only "portable" way to know that mysql
database was initialised is to check for existence of mysql directory in
datadir, which contains system tables.

Such check assumes that installation went fine and then tries to start
mysql. If installation was not correct mysqld will die, which is
acceptable, as wrapper will exit.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44200 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9bc979c3
No related merge requests found
...@@ -522,9 +522,6 @@ SSLRandomSeed connect builtin ...@@ -522,9 +522,6 @@ SSLRandomSeed connect builtin
self.substituteTemplate(self.getTemplateFilename('my.cnf.in'), self.substituteTemplate(self.getTemplateFilename('my.cnf.in'),
mysql_conf)) mysql_conf))
initialise_command_list = [self.options['mysql_install_binary'],
'--skip-name-resolve', '--no-defaults',
'--datadir=%s' % mysql_conf['data_directory']]
mysql_command_list = [self.options['mysql_binary'].strip(), mysql_command_list = [self.options['mysql_binary'].strip(),
'--no-defaults', '-B', '--user=root', '--no-defaults', '-B', '--user=root',
'--socket=%s' % mysql_conf['socket'], '--socket=%s' % mysql_conf['socket'],
...@@ -537,11 +534,14 @@ SSLRandomSeed connect builtin ...@@ -537,11 +534,14 @@ SSLRandomSeed connect builtin
mysql_script])) mysql_script]))
self.path_list.extend(zc.buildout.easy_install.scripts([('mysqld', self.path_list.extend(zc.buildout.easy_install.scripts([('mysqld',
__name__ + '.mysql', 'runMysql')], self.ws, __name__ + '.mysql', 'runMysql')], self.ws,
sys.executable, self.wrapper_directory, arguments=[ sys.executable, self.wrapper_directory, arguments=[dict(
initialise_command_list, { mysql_install_binary=self.options['mysql_install_binary'].strip(),
'mysqld_binary':self.options['mysqld_binary'], mysqld_binary=self.options['mysqld_binary'].strip(),
'configuration_file':mysql_conf_path, data_directory=mysql_conf['data_directory'].strip(),
}])) mysql_binary=self.options['mysql_binary'].strip(),
socket=mysql_conf['socket'].strip(),
configuration_file=mysql_conf_path,
)]))
self.path_list.extend([mysql_conf_path]) self.path_list.extend([mysql_conf_path])
# The return could be more explicit database, user ... # The return could be more explicit database, user ...
return mysql_conf return mysql_conf
...@@ -6,25 +6,29 @@ import time ...@@ -6,25 +6,29 @@ import time
def runMysql(args): def runMysql(args):
sleep = 60 sleep = 60
initialise_command_list = args[0] conf = args[0]
mysql_conf = args[1] mysqld_wrapper_list = [conf['mysqld_binary'], '--defaults-file=%s' %
mysql_wrapper_list = [mysql_conf['mysqld_binary'], conf['configuration_file']]
'--defaults-file=%s' % mysql_conf['configuration_file']] # we trust mysql_install that if mysql directory is available mysql was
while True: # correctly initalised
# XXX: Protect with proper root password if not os.path.isdir(os.path.join(conf['data_directory'], 'mysql')):
popen = subprocess.Popen(initialise_command_list, while True:
stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # XXX: Protect with proper root password
result = popen.communicate()[0] popen = subprocess.Popen([conf['mysql_install_binary'],
if popen.returncode is None or popen.returncode != 0: '--skip-name-resolve', '--no-defaults', '--datadir=%s' %
print "Failed to initialise server.\nThe error was: %s" % result conf['data_directory']],
print "Waiting for %ss and retrying" % sleep stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
time.sleep(sleep) result = popen.communicate()[0]
else: if popen.returncode is None or popen.returncode != 0:
print "Mysql properly initialised" print "Failed to initialise server.\nThe error was: %s" % result
break print "Waiting for %ss and retrying" % sleep
sys.stdout.flush() time.sleep(sleep)
sys.stderr.flush() else:
os.execl(mysql_wrapper_list[0], *mysql_wrapper_list) print "Mysql properly initialised"
break
else:
print "MySQL already initalised, starting"
os.execl(mysqld_wrapper_list[0], *mysqld_wrapper_list)
def updateMysql(args): def updateMysql(args):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment