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
...@@ -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,13 +6,17 @@ import time ...@@ -6,13 +6,17 @@ 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
# correctly initalised
if not os.path.isdir(os.path.join(conf['data_directory'], 'mysql')):
while True: while True:
# XXX: Protect with proper root password # XXX: Protect with proper root password
popen = subprocess.Popen(initialise_command_list, popen = subprocess.Popen([conf['mysql_install_binary'],
'--skip-name-resolve', '--no-defaults', '--datadir=%s' %
conf['data_directory']],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
result = popen.communicate()[0] result = popen.communicate()[0]
if popen.returncode is None or popen.returncode != 0: if popen.returncode is None or popen.returncode != 0:
...@@ -22,9 +26,9 @@ def runMysql(args): ...@@ -22,9 +26,9 @@ def runMysql(args):
else: else:
print "Mysql properly initialised" print "Mysql properly initialised"
break break
sys.stdout.flush() else:
sys.stderr.flush() print "MySQL already initalised, starting"
os.execl(mysql_wrapper_list[0], *mysql_wrapper_list) 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