Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Jun 2014 19:39:27 +0000 (UTC)
From:      Thierry Thomas <thierry@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r356397 - in head/www/tt-rss: . files
Message-ID:  <201406031939.s53JdRL0043084@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: thierry
Date: Tue Jun  3 19:39:27 2014
New Revision: 356397
URL: http://svnweb.freebsd.org/changeset/ports/356397
QAT: https://qat.redports.org/buildarchive/r356397/

Log:
  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>

Modified:
  head/www/tt-rss/Makefile
  head/www/tt-rss/files/ttrssd.in

Modified: head/www/tt-rss/Makefile
==============================================================================
--- head/www/tt-rss/Makefile	Tue Jun  3 19:37:37 2014	(r356396)
+++ head/www/tt-rss/Makefile	Tue Jun  3 19:39:27 2014	(r356397)
@@ -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
 
 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
 

Modified: head/www/tt-rss/files/ttrssd.in
==============================================================================
--- head/www/tt-rss/files/ttrssd.in	Tue Jun  3 19:37:37 2014	(r356396)
+++ head/www/tt-rss/files/ttrssd.in	Tue Jun  3 19:39:27 2014	(r356397)
@@ -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"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406031939.s53JdRL0043084>