aboutsummaryrefslogtreecommitdiffstats
path: root/www
diff options
context:
space:
mode:
authorthierry <thierry@FreeBSD.org>2014-06-04 03:39:27 +0800
committerthierry <thierry@FreeBSD.org>2014-06-04 03:39:27 +0800
commitf66bed58ab550e34b48ca5ec4e16a20242c36e3a (patch)
treef3fc44f02ecfba15e5b50efefec818c3e8b5f248 /www
parent9ec9c5189040043ca41cc1af6ab5b39bde2f07d7 (diff)
downloadfreebsd-ports-gnome-f66bed58ab550e34b48ca5ec4e16a20242c36e3a.tar.gz
freebsd-ports-gnome-f66bed58ab550e34b48ca5ec4e16a20242c36e3a.tar.zst
freebsd-ports-gnome-f66bed58ab550e34b48ca5ec4e16a20242c36e3a.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>
Diffstat (limited to 'www')
-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"