2
0
Fork 0
mirror of https://github.com/friendica/docker synced 2024-05-24 01:34:58 +02: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:
Hypolite Petovan 2018-06-10 11:59:04 -04:00 committed by GitHub
commit 951fdf7773
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 273 additions and 28 deletions

View file

@ -98,6 +98,39 @@ friendica_help() {
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
console() {
if [ -f $WORKDIR/bin/console.php ]; then
@ -177,10 +210,12 @@ install() {
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
[ "$AUTOINSTALL" = "true" ]; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
if check_database; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
fi
fi
}

View file

@ -98,6 +98,39 @@ friendica_help() {
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
console() {
if [ -f $WORKDIR/bin/console.php ]; then
@ -177,10 +210,12 @@ install() {
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
[ "$AUTOINSTALL" = "true" ]; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
if check_database; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
fi
fi
}

View file

@ -98,6 +98,39 @@ friendica_help() {
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
console() {
if [ -f $WORKDIR/bin/console.php ]; then
@ -177,10 +210,12 @@ install() {
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
[ "$AUTOINSTALL" = "true" ]; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
if check_database; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
fi
fi
}

View file

@ -98,6 +98,39 @@ friendica_help() {
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
console() {
if [ -f $WORKDIR/bin/console.php ]; then
@ -177,10 +210,12 @@ install() {
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
[ "$AUTOINSTALL" = "true" ]; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
if check_database; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
fi
fi
}

View file

@ -98,6 +98,39 @@ friendica_help() {
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
console() {
if [ -f $WORKDIR/bin/console.php ]; then
@ -177,10 +210,12 @@ install() {
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
[ "$AUTOINSTALL" = "true" ]; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
if check_database; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
fi
fi
}

View file

@ -98,6 +98,39 @@ friendica_help() {
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
console() {
if [ -f $WORKDIR/bin/console.php ]; then
@ -177,10 +210,12 @@ install() {
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
[ "$AUTOINSTALL" = "true" ]; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
if check_database; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
fi
fi
}

View file

@ -98,6 +98,39 @@ friendica_help() {
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
console() {
if [ -f $WORKDIR/bin/console.php ]; then
@ -177,10 +210,12 @@ install() {
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
[ "$AUTOINSTALL" = "true" ]; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
if check_database; then
run_as "cp ${SOURCEDIR}/config/htconfig.php ${WORKDIR}/.htconfig.php"
console autoinstall -f .htconfig.php
# TODO Workaround because of a strange permission issue
rm -fr ${WORKDIR}/view/smarty3/compiled
fi
fi
}