mirror of
https://github.com/friendica/docker
synced 2025-02-12 15:30:40 +01:00
Merge pull request #24 from nupplaphil/database_retries
Added Datbase retry checks (if Friendica is faster than the DB)
This commit is contained in:
commit
951fdf7773
7 changed files with 273 additions and 28 deletions
|
@ -98,6 +98,39 @@ friendica_help() {
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_database() {
|
||||||
|
TERM=dumb php -- <<'EOPHP'
|
||||||
|
<?php
|
||||||
|
// database might not exist, so let's wait for it (just to be safe)
|
||||||
|
$stderr = fopen('php://stderr', 'w');
|
||||||
|
|
||||||
|
require_once '/usr/src/config/htconfig.php';
|
||||||
|
|
||||||
|
$connection = "mysql:host=".$db_host.";dbname=".$db_data;
|
||||||
|
|
||||||
|
$maxTries = 10;
|
||||||
|
$connected = false;
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
// This docker image is using the PDO library
|
||||||
|
$mysql = @new PDO($connection, $db_user, $db_pass);
|
||||||
|
$connected = true;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n");
|
||||||
|
$connected = false;
|
||||||
|
--$maxTries;
|
||||||
|
if ($maxTries <= 0) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
sleep(3);
|
||||||
|
}
|
||||||
|
} while (!$connected);
|
||||||
|
|
||||||
|
unset($db_user, $db_pass, $db_host, $db_data, $port, $socket);
|
||||||
|
?>
|
||||||
|
EOPHP
|
||||||
|
}
|
||||||
|
|
||||||
# executes the Friendica console
|
# executes the Friendica console
|
||||||
console() {
|
console() {
|
||||||
if [ -f $WORKDIR/bin/console.php ]; then
|
if [ -f $WORKDIR/bin/console.php ]; then
|
||||||
|
@ -177,10 +210,12 @@ install() {
|
||||||
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
||||||
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
||||||
[ "$AUTOINSTALL" = "true" ]; then
|
[ "$AUTOINSTALL" = "true" ]; then
|
||||||
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
|
if check_database; then
|
||||||
console autoinstall -f .htconfig.php
|
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
|
||||||
# TODO Workaround because of a strange permission issue
|
console autoinstall -f .htconfig.php
|
||||||
rm -fr ${WORKDIR}/view/smarty3/compiled
|
# TODO Workaround because of a strange permission issue
|
||||||
|
rm -fr ${WORKDIR}/view/smarty3/compiled
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,39 @@ friendica_help() {
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_database() {
|
||||||
|
TERM=dumb php -- <<'EOPHP'
|
||||||
|
<?php
|
||||||
|
// database might not exist, so let's wait for it (just to be safe)
|
||||||
|
$stderr = fopen('php://stderr', 'w');
|
||||||
|
|
||||||
|
require_once '/usr/src/config/htconfig.php';
|
||||||
|
|
||||||
|
$connection = "mysql:host=".$db_host.";dbname=".$db_data;
|
||||||
|
|
||||||
|
$maxTries = 10;
|
||||||
|
$connected = false;
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
// This docker image is using the PDO library
|
||||||
|
$mysql = @new PDO($connection, $db_user, $db_pass);
|
||||||
|
$connected = true;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n");
|
||||||
|
$connected = false;
|
||||||
|
--$maxTries;
|
||||||
|
if ($maxTries <= 0) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
sleep(3);
|
||||||
|
}
|
||||||
|
} while (!$connected);
|
||||||
|
|
||||||
|
unset($db_user, $db_pass, $db_host, $db_data, $port, $socket);
|
||||||
|
?>
|
||||||
|
EOPHP
|
||||||
|
}
|
||||||
|
|
||||||
# executes the Friendica console
|
# executes the Friendica console
|
||||||
console() {
|
console() {
|
||||||
if [ -f $WORKDIR/bin/console.php ]; then
|
if [ -f $WORKDIR/bin/console.php ]; then
|
||||||
|
@ -177,10 +210,12 @@ install() {
|
||||||
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
||||||
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
||||||
[ "$AUTOINSTALL" = "true" ]; then
|
[ "$AUTOINSTALL" = "true" ]; then
|
||||||
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
|
if check_database; then
|
||||||
console autoinstall -f .htconfig.php
|
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
|
||||||
# TODO Workaround because of a strange permission issue
|
console autoinstall -f .htconfig.php
|
||||||
rm -fr ${WORKDIR}/view/smarty3/compiled
|
# TODO Workaround because of a strange permission issue
|
||||||
|
rm -fr ${WORKDIR}/view/smarty3/compiled
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,39 @@ friendica_help() {
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_database() {
|
||||||
|
TERM=dumb php -- <<'EOPHP'
|
||||||
|
<?php
|
||||||
|
// database might not exist, so let's wait for it (just to be safe)
|
||||||
|
$stderr = fopen('php://stderr', 'w');
|
||||||
|
|
||||||
|
require_once '/usr/src/config/htconfig.php';
|
||||||
|
|
||||||
|
$connection = "mysql:host=".$db_host.";dbname=".$db_data;
|
||||||
|
|
||||||
|
$maxTries = 10;
|
||||||
|
$connected = false;
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
// This docker image is using the PDO library
|
||||||
|
$mysql = @new PDO($connection, $db_user, $db_pass);
|
||||||
|
$connected = true;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n");
|
||||||
|
$connected = false;
|
||||||
|
--$maxTries;
|
||||||
|
if ($maxTries <= 0) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
sleep(3);
|
||||||
|
}
|
||||||
|
} while (!$connected);
|
||||||
|
|
||||||
|
unset($db_user, $db_pass, $db_host, $db_data, $port, $socket);
|
||||||
|
?>
|
||||||
|
EOPHP
|
||||||
|
}
|
||||||
|
|
||||||
# executes the Friendica console
|
# executes the Friendica console
|
||||||
console() {
|
console() {
|
||||||
if [ -f $WORKDIR/bin/console.php ]; then
|
if [ -f $WORKDIR/bin/console.php ]; then
|
||||||
|
@ -177,10 +210,12 @@ install() {
|
||||||
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
||||||
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
||||||
[ "$AUTOINSTALL" = "true" ]; then
|
[ "$AUTOINSTALL" = "true" ]; then
|
||||||
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
|
if check_database; then
|
||||||
console autoinstall -f .htconfig.php
|
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
|
||||||
# TODO Workaround because of a strange permission issue
|
console autoinstall -f .htconfig.php
|
||||||
rm -fr ${WORKDIR}/view/smarty3/compiled
|
# TODO Workaround because of a strange permission issue
|
||||||
|
rm -fr ${WORKDIR}/view/smarty3/compiled
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,39 @@ friendica_help() {
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_database() {
|
||||||
|
TERM=dumb php -- <<'EOPHP'
|
||||||
|
<?php
|
||||||
|
// database might not exist, so let's wait for it (just to be safe)
|
||||||
|
$stderr = fopen('php://stderr', 'w');
|
||||||
|
|
||||||
|
require_once '/usr/src/config/htconfig.php';
|
||||||
|
|
||||||
|
$connection = "mysql:host=".$db_host.";dbname=".$db_data;
|
||||||
|
|
||||||
|
$maxTries = 10;
|
||||||
|
$connected = false;
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
// This docker image is using the PDO library
|
||||||
|
$mysql = @new PDO($connection, $db_user, $db_pass);
|
||||||
|
$connected = true;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n");
|
||||||
|
$connected = false;
|
||||||
|
--$maxTries;
|
||||||
|
if ($maxTries <= 0) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
sleep(3);
|
||||||
|
}
|
||||||
|
} while (!$connected);
|
||||||
|
|
||||||
|
unset($db_user, $db_pass, $db_host, $db_data, $port, $socket);
|
||||||
|
?>
|
||||||
|
EOPHP
|
||||||
|
}
|
||||||
|
|
||||||
# executes the Friendica console
|
# executes the Friendica console
|
||||||
console() {
|
console() {
|
||||||
if [ -f $WORKDIR/bin/console.php ]; then
|
if [ -f $WORKDIR/bin/console.php ]; then
|
||||||
|
@ -177,10 +210,12 @@ install() {
|
||||||
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
||||||
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
||||||
[ "$AUTOINSTALL" = "true" ]; then
|
[ "$AUTOINSTALL" = "true" ]; then
|
||||||
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
|
if check_database; then
|
||||||
console autoinstall -f .htconfig.php
|
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
|
||||||
# TODO Workaround because of a strange permission issue
|
console autoinstall -f .htconfig.php
|
||||||
rm -fr ${WORKDIR}/view/smarty3/compiled
|
# TODO Workaround because of a strange permission issue
|
||||||
|
rm -fr ${WORKDIR}/view/smarty3/compiled
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,39 @@ friendica_help() {
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_database() {
|
||||||
|
TERM=dumb php -- <<'EOPHP'
|
||||||
|
<?php
|
||||||
|
// database might not exist, so let's wait for it (just to be safe)
|
||||||
|
$stderr = fopen('php://stderr', 'w');
|
||||||
|
|
||||||
|
require_once '/usr/src/config/htconfig.php';
|
||||||
|
|
||||||
|
$connection = "mysql:host=".$db_host.";dbname=".$db_data;
|
||||||
|
|
||||||
|
$maxTries = 10;
|
||||||
|
$connected = false;
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
// This docker image is using the PDO library
|
||||||
|
$mysql = @new PDO($connection, $db_user, $db_pass);
|
||||||
|
$connected = true;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n");
|
||||||
|
$connected = false;
|
||||||
|
--$maxTries;
|
||||||
|
if ($maxTries <= 0) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
sleep(3);
|
||||||
|
}
|
||||||
|
} while (!$connected);
|
||||||
|
|
||||||
|
unset($db_user, $db_pass, $db_host, $db_data, $port, $socket);
|
||||||
|
?>
|
||||||
|
EOPHP
|
||||||
|
}
|
||||||
|
|
||||||
# executes the Friendica console
|
# executes the Friendica console
|
||||||
console() {
|
console() {
|
||||||
if [ -f $WORKDIR/bin/console.php ]; then
|
if [ -f $WORKDIR/bin/console.php ]; then
|
||||||
|
@ -177,10 +210,12 @@ install() {
|
||||||
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
||||||
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
||||||
[ "$AUTOINSTALL" = "true" ]; then
|
[ "$AUTOINSTALL" = "true" ]; then
|
||||||
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
|
if check_database; then
|
||||||
console autoinstall -f .htconfig.php
|
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
|
||||||
# TODO Workaround because of a strange permission issue
|
console autoinstall -f .htconfig.php
|
||||||
rm -fr ${WORKDIR}/view/smarty3/compiled
|
# TODO Workaround because of a strange permission issue
|
||||||
|
rm -fr ${WORKDIR}/view/smarty3/compiled
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,39 @@ friendica_help() {
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_database() {
|
||||||
|
TERM=dumb php -- <<'EOPHP'
|
||||||
|
<?php
|
||||||
|
// database might not exist, so let's wait for it (just to be safe)
|
||||||
|
$stderr = fopen('php://stderr', 'w');
|
||||||
|
|
||||||
|
require_once '/usr/src/config/htconfig.php';
|
||||||
|
|
||||||
|
$connection = "mysql:host=".$db_host.";dbname=".$db_data;
|
||||||
|
|
||||||
|
$maxTries = 10;
|
||||||
|
$connected = false;
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
// This docker image is using the PDO library
|
||||||
|
$mysql = @new PDO($connection, $db_user, $db_pass);
|
||||||
|
$connected = true;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n");
|
||||||
|
$connected = false;
|
||||||
|
--$maxTries;
|
||||||
|
if ($maxTries <= 0) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
sleep(3);
|
||||||
|
}
|
||||||
|
} while (!$connected);
|
||||||
|
|
||||||
|
unset($db_user, $db_pass, $db_host, $db_data, $port, $socket);
|
||||||
|
?>
|
||||||
|
EOPHP
|
||||||
|
}
|
||||||
|
|
||||||
# executes the Friendica console
|
# executes the Friendica console
|
||||||
console() {
|
console() {
|
||||||
if [ -f $WORKDIR/bin/console.php ]; then
|
if [ -f $WORKDIR/bin/console.php ]; then
|
||||||
|
@ -177,10 +210,12 @@ install() {
|
||||||
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
||||||
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
||||||
[ "$AUTOINSTALL" = "true" ]; then
|
[ "$AUTOINSTALL" = "true" ]; then
|
||||||
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
|
if check_database; then
|
||||||
console autoinstall -f .htconfig.php
|
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
|
||||||
# TODO Workaround because of a strange permission issue
|
console autoinstall -f .htconfig.php
|
||||||
rm -fr ${WORKDIR}/view/smarty3/compiled
|
# TODO Workaround because of a strange permission issue
|
||||||
|
rm -fr ${WORKDIR}/view/smarty3/compiled
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,39 @@ friendica_help() {
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_database() {
|
||||||
|
TERM=dumb php -- <<'EOPHP'
|
||||||
|
<?php
|
||||||
|
// database might not exist, so let's wait for it (just to be safe)
|
||||||
|
$stderr = fopen('php://stderr', 'w');
|
||||||
|
|
||||||
|
require_once '/usr/src/config/htconfig.php';
|
||||||
|
|
||||||
|
$connection = "mysql:host=".$db_host.";dbname=".$db_data;
|
||||||
|
|
||||||
|
$maxTries = 10;
|
||||||
|
$connected = false;
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
// This docker image is using the PDO library
|
||||||
|
$mysql = @new PDO($connection, $db_user, $db_pass);
|
||||||
|
$connected = true;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n");
|
||||||
|
$connected = false;
|
||||||
|
--$maxTries;
|
||||||
|
if ($maxTries <= 0) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
sleep(3);
|
||||||
|
}
|
||||||
|
} while (!$connected);
|
||||||
|
|
||||||
|
unset($db_user, $db_pass, $db_host, $db_data, $port, $socket);
|
||||||
|
?>
|
||||||
|
EOPHP
|
||||||
|
}
|
||||||
|
|
||||||
# executes the Friendica console
|
# executes the Friendica console
|
||||||
console() {
|
console() {
|
||||||
if [ -f $WORKDIR/bin/console.php ]; then
|
if [ -f $WORKDIR/bin/console.php ]; then
|
||||||
|
@ -177,10 +210,12 @@ install() {
|
||||||
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
||||||
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
||||||
[ "$AUTOINSTALL" = "true" ]; then
|
[ "$AUTOINSTALL" = "true" ]; then
|
||||||
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
|
if check_database; then
|
||||||
console autoinstall -f .htconfig.php
|
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
|
||||||
# TODO Workaround because of a strange permission issue
|
console autoinstall -f .htconfig.php
|
||||||
rm -fr ${WORKDIR}/view/smarty3/compiled
|
# TODO Workaround because of a strange permission issue
|
||||||
|
rm -fr ${WORKDIR}/view/smarty3/compiled
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue