erp5: mariadb import script: kill mysqld process in trap.

parent f3b00406
...@@ -150,13 +150,13 @@ context = ...@@ -150,13 +150,13 @@ context =
[mariadb-resiliency-after-import-script] [mariadb-resiliency-after-import-script]
recipe = slapos.recipe.build:download recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/template/instance-mariadb-resiliency-after-import-script.sh.in url = ${:_profile_base_location_}/template/instance-mariadb-resiliency-after-import-script.sh.in
md5sum = a4738534a7e0e19af8a6e90e24029cf3 md5sum = 5a300e69a5984cd0e4f5fe91c0c54aac
mode = 755 mode = 755
[template-mariadb] [template-mariadb]
recipe = slapos.recipe.build:download recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/instance-mariadb.cfg.in url = ${:_profile_base_location_}/instance-mariadb.cfg.in
md5sum = c78c8a6445a5f67dca35c427ae370d84 md5sum = f8da9d6bb5da207d3ecadf2bba499616
mode = 640 mode = 640
[template-zope] [template-zope]
...@@ -199,7 +199,7 @@ mode = 640 ...@@ -199,7 +199,7 @@ mode = 640
# XXX: "template.cfg" is hardcoded in instanciation recipe # XXX: "template.cfg" is hardcoded in instanciation recipe
filename = template.cfg filename = template.cfg
template = ${:_profile_base_location_}/instance.cfg.in template = ${:_profile_base_location_}/instance.cfg.in
md5sum = 78aeabeb306178e4716b44ad6605c59c md5sum = 0d777bfc8377e5b8ddc2e32a10f45b9b
extra-context = extra-context =
key apache_location apache:location key apache_location apache:location
key aspell_location aspell:location key aspell_location aspell:location
......
...@@ -209,6 +209,7 @@ recipe = collective.recipe.template ...@@ -209,6 +209,7 @@ recipe = collective.recipe.template
input = {{ mariadb_resiliency_after_import_script }} input = {{ mariadb_resiliency_after_import_script }}
output = ${rootdirectory:srv}/runner-import-restore output = ${rootdirectory:srv}/runner-import-restore
mode = 755 mode = 755
dash_location = {{ dash_location }}
[rootdirectory] [rootdirectory]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:mkdirectory
......
...@@ -134,6 +134,7 @@ filename = instance-mariadb.cfg ...@@ -134,6 +134,7 @@ filename = instance-mariadb.cfg
extra-context = extra-context =
section parameter_dict dynamic-template-mariadb-parameters section parameter_dict dynamic-template-mariadb-parameters
raw coreutils_location {{ coreutils_location }} raw coreutils_location {{ coreutils_location }}
raw dash_location {{ dash_location }}
raw dcron_location {{ dcron_location }} raw dcron_location {{ dcron_location }}
raw findutils_location {{ findutils_location }} raw findutils_location {{ findutils_location }}
raw gettext_location {{ gettext_location }} raw gettext_location {{ gettext_location }}
......
#!/bin/sh #!{{ dash_location }}
# DO NOT RUN THIS SCRIPT ON PRODUCTION INSTANCE # DO NOT RUN THIS SCRIPT ON PRODUCTION INSTANCE
# OR MYSQL DATA WILL BE ERASED. # OR MYSQL DATA WILL BE ERASED.
...@@ -40,12 +40,13 @@ echo "Starting mariadb..." ...@@ -40,12 +40,13 @@ echo "Starting mariadb..."
# XXX hardcoded # XXX hardcoded
$instance_directory/etc/run/mariadb & $instance_directory/etc/run/mariadb &
mysqld_pid=$! mysqld_pid=$!
sleep 15 trap "kill $mysqld_pid" EXIT TERM INT
sleep 30
# If mysql has stopped, abort # If mysql has stopped, abort
if ! $(kill -0 $mysql_pid 2>/dev/null); then if ! [ -d /proc/$mysql_pid ]; then
exit 1 exit 1
fi fi
$instance_directory/etc/run/mariadb_update > /dev/null 2>&1 $instance_directory/etc/run/mariadb_update
echo "Importing data..." echo "Importing data..."
# Use latest dump XXX can contain funny characters # Use latest dump XXX can contain funny characters
...@@ -53,8 +54,6 @@ dump=$(ls -r $mariadb_backup_directory | head -1) ...@@ -53,8 +54,6 @@ dump=$(ls -r $mariadb_backup_directory | head -1)
zcat "$mariadb_backup_directory/$dump" | $mysql_executable -u root --socket="$instance_directory/var/run/mariadb.sock" zcat "$mariadb_backup_directory/$dump" | $mysql_executable -u root --socket="$instance_directory/var/run/mariadb.sock"
RESTORE_EXIT_CODE=$? RESTORE_EXIT_CODE=$?
kill "$mysqld_pid"
if [ $RESTORE_EXIT_CODE -eq 0 ]; then if [ $RESTORE_EXIT_CODE -eq 0 ]; then
echo 'Backup restoration successfully completed.' echo 'Backup restoration successfully completed.'
else else
......
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