mirror of
https://github.com/friendica/docker
synced 2025-02-08 04:51:44 +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
|
||||
}
|
||||
|
||||
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,11 +210,13 @@ install() {
|
|||
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
||||
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
||||
[ "$AUTOINSTALL" = "true" ]; then
|
||||
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
|
||||
}
|
||||
|
||||
update() {
|
||||
|
|
|
@ -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,11 +210,13 @@ install() {
|
|||
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
||||
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
||||
[ "$AUTOINSTALL" = "true" ]; then
|
||||
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
|
||||
}
|
||||
|
||||
update() {
|
||||
|
|
|
@ -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,11 +210,13 @@ install() {
|
|||
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
||||
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
||||
[ "$AUTOINSTALL" = "true" ]; then
|
||||
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
|
||||
}
|
||||
|
||||
update() {
|
||||
|
|
|
@ -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,11 +210,13 @@ install() {
|
|||
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
||||
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
||||
[ "$AUTOINSTALL" = "true" ]; then
|
||||
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
|
||||
}
|
||||
|
||||
update() {
|
||||
|
|
|
@ -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,11 +210,13 @@ install() {
|
|||
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
||||
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
||||
[ "$AUTOINSTALL" = "true" ]; then
|
||||
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
|
||||
}
|
||||
|
||||
update() {
|
||||
|
|
|
@ -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,11 +210,13 @@ install() {
|
|||
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
||||
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
||||
[ "$AUTOINSTALL" = "true" ]; then
|
||||
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
|
||||
}
|
||||
|
||||
update() {
|
||||
|
|
|
@ -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,11 +210,13 @@ install() {
|
|||
if [ ! -f ${WORKDIR}/.htconfig.php ] &&
|
||||
[ -f ${SOURCEDIR}/config/htconfig.php ] &&
|
||||
[ "$AUTOINSTALL" = "true" ]; then
|
||||
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
|
||||
}
|
||||
|
||||
update() {
|
||||
|
|
Loading…
Reference in a new issue