aboutsummaryrefslogtreecommitdiff
path: root/www/tt-rss
diff options
context:
space:
mode:
authorThierry Thomas <thierry@FreeBSD.org>2014-06-03 19:39:27 +0000
committerThierry Thomas <thierry@FreeBSD.org>2014-06-03 19:39:27 +0000
commit526020f791d950fb13b83fed62956cedde2a221a (patch)
treef3fc44f02ecfba15e5b50efefec818c3e8b5f248 /www/tt-rss
parent5a2d77b7d49ee15578c35b7b4012b6a574f607b1 (diff)
downloadports-526020f791d950fb13b83fed62956cedde2a221a.tar.gz
ports-526020f791d950fb13b83fed62956cedde2a221a.zip
It has been reported that sometimes the dæmon is launched before the
database get available, this patch tries to fix that: - add an option to teach if the DB is distant; - for mysql, run `mysqladmin ping' (use a fake account, because not authorized for root!) - for pgsl, run `postgresql status' (pg_isready is not available before 9.3). Reported by: Mike Brown <mike (at) skew.org>
Notes
Notes: svn path=/head/; revision=356397
Diffstat (limited to 'www/tt-rss')
-rw-r--r--www/tt-rss/Makefile18
-rw-r--r--www/tt-rss/files/ttrssd.in21
2 files changed, 36 insertions, 3 deletions
diff --git a/www/tt-rss/Makefile b/www/tt-rss/Makefile
index 229866e6ed79..c7e82639c98b 100644
--- a/www/tt-rss/Makefile
+++ b/www/tt-rss/Makefile
@@ -3,6 +3,7 @@
PORTNAME= tt-rss
PORTVERSION= 1.12
+PORTREVISION= 1
CATEGORIES= www
MAINTAINER= thierry@FreeBSD.org
@@ -27,21 +28,26 @@ SHEBANG_FILES= lib/dojo-src/rebuild-dojo.sh utils/extract-i18n-js.pl
USE_RC_SUBR= ttrssd
-OPTIONS_DEFINE= CURL GD
+OPTIONS_DEFINE= CURL GD DBLOCAL
OPTIONS_SINGLE= DB
OPTIONS_SINGLE_DB= MYSQL PGSQL
-OPTIONS_DEFAULT= CURL GD MYSQL
+OPTIONS_DEFAULT= CURL GD MYSQL DBLOCAL
CURL_DESC= Use SimplePie instead of Magpie
GD_DESC= Use OTP QR code generation
+DBLOCAL_DESC= Database is local?
.include <bsd.port.options.mk>
.if ${PORT_OPTIONS:MPGSQL}
USE_PHP+= pgsql
DB= pgsql
+MYSQL= "\#"
+PGSQL=
.else
USE_PHP+= mysql
DB= mysql
+MYSQL=
+PGSQL= "\#"
.endif
.if ${PORT_OPTIONS:MCURL}
@@ -52,8 +58,14 @@ USE_PHP+= curl
USE_PHP+= gd
.endif
+.if ${PORT_OPTIONS:MDBLOCAL}
+DBLOCAL=
+.else
+DBLOCAL= "\#"
+.endif
+
SUB_FILES= httpd-tt-rss.conf pkg-message
-SUB_LIST= DB=${DB} WWWOWN=${WWWOWN}
+SUB_LIST= DB=${DB} WWWOWN=${WWWOWN} MYSQL=${MYSQL} PGSQL=${PGSQL} DBLOCAL=${DBLOCAL}
PLIST_SUB= WWWOWN=${WWWOWN} WWWGRP=${WWWGRP}
PKGMESSAGE= ${WRKDIR}/pkg-message
diff --git a/www/tt-rss/files/ttrssd.in b/www/tt-rss/files/ttrssd.in
index bee6640ef28f..6d66e09570a4 100644
--- a/www/tt-rss/files/ttrssd.in
+++ b/www/tt-rss/files/ttrssd.in
@@ -30,9 +30,16 @@ phpupd="update_daemon2.php"
ttrssd_log="/var/log/${name}.log"
ttrssd_user="%%WWWOWN%%"
+%%DBLOCAL%%start_precmd=${name}_prestart
start_cmd=${name}_start
stop_cmd=${name}_stop
+%%MYSQL%%CHECK_CMD="%%LOCALBASE%%/bin/mysqladmin -u mysqld ping"
+%%MYSQL%%CHECK_MSG="${name}: mysqladmin command failed; mysql not ready?"
+# Waiting for pg_isready when 9.3 is the default
+%%PGSQL%%CHECK_CMD="%%LOCALBASE%%/etc/rc.d/postgresql status"
+%%PGSQL%%CHECK_MSG="${name}: postgresql status failed; postgresql not ready?"
+
ttrssd_start() {
[ -x $phpcli ] || (echo "$phpcli not found"; exit 1)
[ -f $pidfile ] && (echo "$name already running?"; exit 2)
@@ -48,4 +55,18 @@ ttrssd_stop() {
rm -f $pidfile
}
+ttrssd_prestart() {
+local _count=0
+
+ while : ; do
+ $CHECK_CMD > /dev/null 2>&1 && return
+ _count=$(( $_count + 1 ))
+ if [ $_count -gt 10 ]; then
+ err 1 $CHECK_MSG
+ fi
+
+ sleep 1
+ done
+}
+
run_rc_command "$1"