From 81bdd6ff725137b91a93d303b2c7b9ef7bb280c8 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 10 Jun 2018 13:44:33 +0200 Subject: [PATCH 1/2] Added Datbase retry checks (if Friendica is faster than the DB) --- .bin/friendica | 43 +++++++++++++++++++++++++--- 2018.05/apache/bin/friendica | 43 +++++++++++++++++++++++++--- 2018.05/fpm-alpine/bin/friendica | 43 +++++++++++++++++++++++++--- 2018.05/fpm/bin/friendica | 43 +++++++++++++++++++++++++--- 2018.08-dev/apache/bin/friendica | 43 +++++++++++++++++++++++++--- 2018.08-dev/fpm-alpine/bin/friendica | 43 +++++++++++++++++++++++++--- 2018.08-dev/fpm/bin/friendica | 43 +++++++++++++++++++++++++--- 7 files changed, 273 insertions(+), 28 deletions(-) diff --git a/.bin/friendica b/.bin/friendica index 1a0e3fb..e9abd27 100644 --- a/.bin/friendica +++ b/.bin/friendica @@ -98,6 +98,39 @@ friendica_help() { exit 0 } +check_database() { + TERM=dumb php -- <<'EOPHP' + +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 } diff --git a/2018.05/apache/bin/friendica b/2018.05/apache/bin/friendica index 1a0e3fb..b2ea66e 100644 --- a/2018.05/apache/bin/friendica +++ b/2018.05/apache/bin/friendica @@ -98,6 +98,39 @@ friendica_help() { exit 0 } +check_database() { + TERM=dumb php -- <<'EOPHP' + +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 } diff --git a/2018.05/fpm-alpine/bin/friendica b/2018.05/fpm-alpine/bin/friendica index 1a0e3fb..b2ea66e 100644 --- a/2018.05/fpm-alpine/bin/friendica +++ b/2018.05/fpm-alpine/bin/friendica @@ -98,6 +98,39 @@ friendica_help() { exit 0 } +check_database() { + TERM=dumb php -- <<'EOPHP' + +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 } diff --git a/2018.05/fpm/bin/friendica b/2018.05/fpm/bin/friendica index 1a0e3fb..b2ea66e 100644 --- a/2018.05/fpm/bin/friendica +++ b/2018.05/fpm/bin/friendica @@ -98,6 +98,39 @@ friendica_help() { exit 0 } +check_database() { + TERM=dumb php -- <<'EOPHP' + +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 } diff --git a/2018.08-dev/apache/bin/friendica b/2018.08-dev/apache/bin/friendica index 1a0e3fb..b2ea66e 100644 --- a/2018.08-dev/apache/bin/friendica +++ b/2018.08-dev/apache/bin/friendica @@ -98,6 +98,39 @@ friendica_help() { exit 0 } +check_database() { + TERM=dumb php -- <<'EOPHP' + +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 } diff --git a/2018.08-dev/fpm-alpine/bin/friendica b/2018.08-dev/fpm-alpine/bin/friendica index 1a0e3fb..b2ea66e 100644 --- a/2018.08-dev/fpm-alpine/bin/friendica +++ b/2018.08-dev/fpm-alpine/bin/friendica @@ -98,6 +98,39 @@ friendica_help() { exit 0 } +check_database() { + TERM=dumb php -- <<'EOPHP' + +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 } diff --git a/2018.08-dev/fpm/bin/friendica b/2018.08-dev/fpm/bin/friendica index 1a0e3fb..b2ea66e 100644 --- a/2018.08-dev/fpm/bin/friendica +++ b/2018.08-dev/fpm/bin/friendica @@ -98,6 +98,39 @@ friendica_help() { exit 0 } +check_database() { + TERM=dumb php -- <<'EOPHP' + +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 } From 733bf8a0bafce06330d0d3cf00eb9bad546890c6 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 10 Jun 2018 13:47:31 +0200 Subject: [PATCH 2/2] Added different error-msg --- 2018.05/apache/bin/friendica | 2 +- 2018.05/fpm-alpine/bin/friendica | 2 +- 2018.05/fpm/bin/friendica | 2 +- 2018.08-dev/apache/bin/friendica | 2 +- 2018.08-dev/fpm-alpine/bin/friendica | 2 +- 2018.08-dev/fpm/bin/friendica | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/2018.05/apache/bin/friendica b/2018.05/apache/bin/friendica index b2ea66e..e9abd27 100644 --- a/2018.05/apache/bin/friendica +++ b/2018.05/apache/bin/friendica @@ -116,7 +116,7 @@ do { $mysql = @new PDO($connection, $db_user, $db_pass); $connected = true; } catch (PDOException $e) { - fwrite($stderr, "MySQL Connection Error\n"); + fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n"); $connected = false; --$maxTries; if ($maxTries <= 0) { diff --git a/2018.05/fpm-alpine/bin/friendica b/2018.05/fpm-alpine/bin/friendica index b2ea66e..e9abd27 100644 --- a/2018.05/fpm-alpine/bin/friendica +++ b/2018.05/fpm-alpine/bin/friendica @@ -116,7 +116,7 @@ do { $mysql = @new PDO($connection, $db_user, $db_pass); $connected = true; } catch (PDOException $e) { - fwrite($stderr, "MySQL Connection Error\n"); + fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n"); $connected = false; --$maxTries; if ($maxTries <= 0) { diff --git a/2018.05/fpm/bin/friendica b/2018.05/fpm/bin/friendica index b2ea66e..e9abd27 100644 --- a/2018.05/fpm/bin/friendica +++ b/2018.05/fpm/bin/friendica @@ -116,7 +116,7 @@ do { $mysql = @new PDO($connection, $db_user, $db_pass); $connected = true; } catch (PDOException $e) { - fwrite($stderr, "MySQL Connection Error\n"); + fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n"); $connected = false; --$maxTries; if ($maxTries <= 0) { diff --git a/2018.08-dev/apache/bin/friendica b/2018.08-dev/apache/bin/friendica index b2ea66e..e9abd27 100644 --- a/2018.08-dev/apache/bin/friendica +++ b/2018.08-dev/apache/bin/friendica @@ -116,7 +116,7 @@ do { $mysql = @new PDO($connection, $db_user, $db_pass); $connected = true; } catch (PDOException $e) { - fwrite($stderr, "MySQL Connection Error\n"); + fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n"); $connected = false; --$maxTries; if ($maxTries <= 0) { diff --git a/2018.08-dev/fpm-alpine/bin/friendica b/2018.08-dev/fpm-alpine/bin/friendica index b2ea66e..e9abd27 100644 --- a/2018.08-dev/fpm-alpine/bin/friendica +++ b/2018.08-dev/fpm-alpine/bin/friendica @@ -116,7 +116,7 @@ do { $mysql = @new PDO($connection, $db_user, $db_pass); $connected = true; } catch (PDOException $e) { - fwrite($stderr, "MySQL Connection Error\n"); + fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n"); $connected = false; --$maxTries; if ($maxTries <= 0) { diff --git a/2018.08-dev/fpm/bin/friendica b/2018.08-dev/fpm/bin/friendica index b2ea66e..e9abd27 100644 --- a/2018.08-dev/fpm/bin/friendica +++ b/2018.08-dev/fpm/bin/friendica @@ -116,7 +116,7 @@ do { $mysql = @new PDO($connection, $db_user, $db_pass); $connected = true; } catch (PDOException $e) { - fwrite($stderr, "MySQL Connection Error\n"); + fwrite($stderr, "\nMySQL Connection Error: " . $e . "\n"); $connected = false; --$maxTries; if ($maxTries <= 0) {