Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
erp5
Commits
defae9b0
Commit
defae9b0
authored
Jun 01, 2011
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First version of standalone mysql recipe
parent
801f4a49
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
357 additions
and
0 deletions
+357
-0
slapos/recipe/README.mysql.txt
slapos/recipe/README.mysql.txt
+4
-0
slapos/recipe/mysql/__init__.py
slapos/recipe/mysql/__init__.py
+228
-0
slapos/recipe/mysql/mysql.py
slapos/recipe/mysql/mysql.py
+71
-0
slapos/recipe/mysql/template/initmysql.sql.in
slapos/recipe/mysql/template/initmysql.sql.in
+2
-0
slapos/recipe/mysql/template/my.cnf.in
slapos/recipe/mysql/template/my.cnf.in
+52
-0
No files found.
slapos/recipe/README.mysql.txt
0 → 100644
View file @
defae9b0
mysql
=========
Instantiates MySQL instance.
slapos/recipe/mysql/__init__.py
0 → 100644
View file @
defae9b0
This diff is collapsed.
Click to expand it.
slapos/recipe/mysql/mysql.py
0 → 100644
View file @
defae9b0
import
os
import
subprocess
import
time
import
sys
def
runMysql
(
args
):
sleep
=
60
conf
=
args
[
0
]
mysqld_wrapper_list
=
[
conf
[
'mysqld_binary'
],
'--defaults-file=%s'
%
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
:
# XXX: Protect with proper root password
# XXX: Follow http://dev.mysql.com/doc/refman/5.0/en/default-privileges.html
popen
=
subprocess
.
Popen
([
conf
[
'mysql_install_binary'
],
'--skip-name-resolve'
,
'--no-defaults'
,
'--datadir=%s'
%
conf
[
'data_directory'
]],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
result
=
popen
.
communicate
()[
0
]
if
popen
.
returncode
is
None
or
popen
.
returncode
!=
0
:
print
"Failed to initialise server.
\
n
The error was: %s"
%
result
print
"Waiting for %ss and retrying"
%
sleep
time
.
sleep
(
sleep
)
else
:
print
"Mysql properly initialised"
break
else
:
print
"MySQL already initialised"
print
"Starting %r"
%
mysqld_wrapper_list
[
0
]
sys
.
stdout
.
flush
()
sys
.
stderr
.
flush
()
os
.
execl
(
mysqld_wrapper_list
[
0
],
*
mysqld_wrapper_list
)
def
updateMysql
(
args
):
conf
=
args
[
0
]
sleep
=
30
is_succeed
=
False
while
True
:
if
not
is_succeed
:
mysql_upgrade_list
=
[
conf
[
'mysql_upgrade_binary'
],
'--no-defaults'
,
'--user=root'
,
'--socket=%s'
%
conf
[
'socket'
]]
mysql_upgrade
=
subprocess
.
Popen
(
mysql_upgrade_list
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
result
=
mysql_upgrade
.
communicate
()[
0
]
if
mysql_upgrade
.
returncode
is
None
:
mysql_upgrade
.
kill
()
if
mysql_upgrade
.
returncode
!=
0
and
not
'is already upgraded'
in
result
:
print
"Command %r failed with result:
\
n
%s"
%
(
mysql_upgrade_list
,
result
)
print
'Sleeping for %ss and retrying'
%
sleep
else
:
if
mysql_upgrade
.
returncode
==
0
:
print
"MySQL database upgraded with result:
\
n
%s"
%
result
else
:
print
"No need to upgrade MySQL database"
mysql_list
=
[
conf
[
'mysql_binary'
].
strip
(),
'--no-defaults'
,
'-B'
,
'--user=root'
,
'--socket=%s'
%
conf
[
'socket'
]]
mysql
=
subprocess
.
Popen
(
mysql_list
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
result
=
mysql
.
communicate
(
conf
[
'mysql_script'
])[
0
]
if
mysql
.
returncode
is
None
:
mysql
.
kill
()
if
mysql
.
returncode
!=
0
:
print
'Command %r failed with:
\
n
%s'
%
(
mysql_list
,
result
)
print
'Sleeping for %ss and retrying'
%
sleep
else
:
is_succeed
=
True
print
'SlapOS initialisation script succesfully applied on database.'
sys
.
stdout
.
flush
()
sys
.
stderr
.
flush
()
time
.
sleep
(
sleep
)
slapos/recipe/mysql/template/initmysql.sql.in
0 → 100644
View file @
defae9b0
CREATE DATABASE IF NOT EXISTS %(mysql_database)s;
GRANT ALL PRIVILEGES ON %(mysql_database)s.* TO %(mysql_user)s@'%%' IDENTIFIED BY '%(mysql_password)s';
slapos/recipe/mysql/template/my.cnf.in
0 → 100644
View file @
defae9b0
# ERP5 buildout my.cnf template based on my-huge.cnf shipped with mysql
# The MySQL server
[mysqld]
# ERP5 by default requires InnoDB storage. MySQL by default fallbacks to using
# different engine, like MyISAM. Such behaviour generates problems only, when
# tables requested as InnoDB are silently created with MyISAM engine.
#
# Loud fail is really required in such case.
sql-mode="NO_ENGINE_SUBSTITUTION"
skip-show-database
port = %(tcp_port)s
bind-address = %(ip)s
socket = %(socket)s
datadir = %(data_directory)s
pid-file = %(pid_file)s
log-error = %(error_log)s
log-slow-file = %(slow_query_log)s
long_query_time = 5
max_allowed_packet = 128M
query_cache_size = 32M
plugin-load = ha_innodb_plugin.so
# The following are important to configure and depend a lot on to the size of
# your database and the available resources.
#innodb_buffer_pool_size = 4G
#innodb_log_file_size = 256M
#innodb_log_buffer_size = 8M
# Some dangerous settings you may want to uncomment if you only want
# performance or less disk access. Useful for unit tests.
#innodb_flush_log_at_trx_commit = 0
#innodb_flush_method = nosync
#innodb_doublewrite = 0
#sync_frm = 0
# Uncomment the following if you need binary logging, which is recommended
# on production instances (either for replication or incremental backups).
#log-bin=mysql-bin
# Force utf8 usage
collation_server = utf8_unicode_ci
character_set_server = utf8
skip-character-set-client-handshake
[mysql]
no-auto-rehash
socket = %(socket)s
[mysqlhotcopy]
interactive-timeout
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment