git: 6f192cd6ff6f - main - www/tt-rss: Simplify ttrssd rc script
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 08 Sep 2024 07:43:33 UTC
The branch main has been updated by pi: URL: https://cgit.FreeBSD.org/ports/commit/?id=6f192cd6ff6fe999d30350a814edd12dbbeca98e commit 6f192cd6ff6fe999d30350a814edd12dbbeca98e Author: Derek Schrock <dereks@lifeofadishwasher.com> AuthorDate: 2024-09-08 07:40:10 +0000 Commit: Kurt Jaeger <pi@FreeBSD.org> CommitDate: 2024-09-08 07:40:10 +0000 www/tt-rss: Simplify ttrssd rc script ttrssd rc script has a check if a local database is ready such that at startup ttrssd will wait 10 seconds for a database connection. With daemon you can restart the child process with a delay such that the rc script can be simplified to use command and command_args. PR: 279803 Author: Derek Schrock <dereks@lifeofadishwasher.com> Reviewed-by: cy Differential Revision: https://reviews.freebsd.org/D45618 --- UPDATING | 8 +++ www/tt-rss/Makefile | 6 +- www/tt-rss/distinfo | 2 +- www/tt-rss/files/ttrss_db_check.php.in | 8 --- www/tt-rss/files/ttrssd.in | 103 +++++++++++---------------------- www/tt-rss/pkg-plist | 1 - 6 files changed, 44 insertions(+), 84 deletions(-) diff --git a/UPDATING b/UPDATING index 4217eb625b9e..f72ab255b66e 100644 --- a/UPDATING +++ b/UPDATING @@ -5,6 +5,14 @@ they are unavoidable. You should get into the habit of checking this file for changes each time you update your ports collection, before attempting any port upgrades. +20240907: + AFFECTS: www/tt-rss + AUTHOR: dereks@lifeofadishwasher.com + + The ttrssd_local_db rc var has been removed in favor of using daemon's + restart option -r to retry the ttrssd php scripts if database is not up + before ttrssd starts. + 20240829: AFFECTS: devel/binutils AUTHOR: cy@FreeBSD.org diff --git a/www/tt-rss/Makefile b/www/tt-rss/Makefile index d3e5cc102966..422d353d9f0c 100644 --- a/www/tt-rss/Makefile +++ b/www/tt-rss/Makefile @@ -1,6 +1,6 @@ PORTNAME= tt-rss PORTVERSION= g20240421 -PORTREVISION= 2 +PORTREVISION= 3 PORTEPOCH= 2 CATEGORIES= www PKGNAMESUFFIX= ${PHP_PKGNAMESUFFIX} @@ -37,7 +37,7 @@ NO_BUILD= yes # pgsql: php-pgsql php-pdo_pgsql # # from Mk/Uses/php.mk create sub vars for mysqli/pdo_mysql pgsql/pdo_pgsql values -SUB_FILES= config.php httpd-tt-rss.conf pkg-message ttrss_db_check.php +SUB_FILES= config.php httpd-tt-rss.conf pkg-message SUB_LIST= MYSQL_DEPS="${mysqli_DEPENDS:T} ${pdo_mysql_DEPENDS:T}" \ PGSQL_DEPS="${pgsql_DEPENDS:T} ${pdo_pgsql_DEPENDS:T}" \ WWWOWN=${WWWOWN} @@ -68,8 +68,6 @@ do-install: ${RM} ${STAGEDIR}${WWWDIR}/config.php-dist ${INSTALL_DATA} ${WRKDIR}/config.php \ ${STAGEDIR}${WWWDIR}/config.php.sample - ${INSTALL_DATA} ${WRKDIR}/ttrss_db_check.php \ - ${STAGEDIR}${WWWDIR}/ttrss_db_check.php ${INSTALL_DATA} ${FILESDIR}/newsyslog.sample \ ${STAGEDIR}${EXAMPLESDIR} diff --git a/www/tt-rss/distinfo b/www/tt-rss/distinfo index 7821d80336d3..2274a9a08d04 100644 --- a/www/tt-rss/distinfo +++ b/www/tt-rss/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1713836306 +TIMESTAMP = 1721519279 SHA256 (tt-rss-tt-rss-d832907125a7711397da8ade5cfb51082d802542_GL0.tar.gz) = 21754aa85eaa4a5de1aba6e076f26ca3c356a4d6e70ae7e1d9e6ea6d12de1d65 SIZE (tt-rss-tt-rss-d832907125a7711397da8ade5cfb51082d802542_GL0.tar.gz) = 8995458 diff --git a/www/tt-rss/files/ttrss_db_check.php.in b/www/tt-rss/files/ttrss_db_check.php.in deleted file mode 100644 index cbc7aaac8828..000000000000 --- a/www/tt-rss/files/ttrss_db_check.php.in +++ /dev/null @@ -1,8 +0,0 @@ -<?php -chdir("%%WWWDIR%%"); - -require_once "%%WWWDIR%%/classes/Config.php"; -require_once "%%WWWDIR%%/include/autoload.php"; - -print(strtolower(Config::get(Config::DB_TYPE))); -?> diff --git a/www/tt-rss/files/ttrssd.in b/www/tt-rss/files/ttrssd.in index a92d4464df53..7934b98a4afc 100644 --- a/www/tt-rss/files/ttrssd.in +++ b/www/tt-rss/files/ttrssd.in @@ -1,16 +1,12 @@ #! /bin/sh # PROVIDE: ttrssd -# REQUIRE: LOGIN mysql postgresql +# REQUIRE: LOGIN # KEYWORD: shutdown # Add the following lines to /etc/rc.conf to enable `ttrssd': # # ttrssd_enable="YES" -# -# ttrssd_local_db (bool): Set to "YES" by default. -# Set it to "NO" if the database is on another -# server. . /etc/rc.subr @@ -22,85 +18,52 @@ rcvar=ttrssd_enable # read settings, set default values load_rc_config "${name}" : ${ttrssd_enable="NO"} -: ${ttrssd_local_db:="YES"} -initdb_php="%%WWWDIR%%/update.php" -dbcheck_php="%%WWWDIR%%/ttrss_db_check.php" +long_name="Tiny Tiny RSS updating feeds daemon." required_files="%%WWWDIR%%/config.php" pidfile="/var/run/${name}.pid" -ppidfile="/var/run/${name}_parent.pid" +cpidfile="/var/run/${name}_child.pid" phpcli="%%LOCALBASE%%/bin/php" -command_interpreter=$phpcli -long_name="Tiny Tiny RSS updating feeds daemon." + +initdb_php="%%WWWDIR%%/update.php" phpupd="%%WWWDIR%%/update_daemon2.php" ttrssd_log="/var/log/${name}.log" -ttrssd_user="%%WWWOWN%%" -start_precmd=${name}_prestart -start_cmd=${name}_start -stop_cmd=${name}_stop +command="/usr/sbin/daemon" +command_args="-rR 10 -H -u %%WWWOWN%% \ + -P $pidfile -p $cpidfile \ + -o $ttrssd_log sh -c \ + '$initdb_php --update-schema=force-yes; \ + $phpupd;'" -MYSQL_CHECK_CMD="%%LOCALBASE%%/bin/mysqladmin -u mysqld ping" -MYSQL_CHECK_MSG="${name}: mysqladmin command failed; mysql not ready?" -PGSQL_CHECK_CMD="%%LOCALBASE%%/bin/pg_isready" -PGSQL_CHECK_MSG="${name}: postgresql status failed; postgresql not ready?" +stop_cmd="${name}_stop" -ttrssd_start() { - if ! [ -x $phpcli ]; then - echo "$phpcli not found" - exit 1 - fi +# daemon doesn't process signals if it lacks a child process. +# See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277959 +ttrssd_stop() { + local pid_daemon + local pid_child + local signal="TERM" - if [ -f $pidfile ]; then - echo "$name already running?" - exit 2 - fi + pid_daemon=$(check_pidfile ${pidfile} ${command}) + pid_child=$(check_pidfile ${cpidfile} ${phpcli}) - echo "Starting $long_name" - daemon -H -P "$ppidfile" -p "$pidfile" \ - -u "$ttrssd_user" -o "$ttrssd_log" \ - sh -c "${initdb_php} --update-schema=force-yes; $phpupd" -} + if [ -n "$pid_daemon" ]; then + echo "Stopping ${name}." -ttrssd_stop() { - if ! [ -f $pidfile ]; then - echo "$name not running?" - exit 1 - fi + if [ -z "${pid_child}" ]; then + signal="INT" + fi - echo "Stopping $long_name" - pkill -CHLD -F "$pidfile" - pkill -F "$pidfile" - pwait "$(cat $ppidfile)" -} + kill -"$signal" "${pid_daemon}" -ttrssd_prestart() { - if checkyesno ttrssd_local_db; then - # Wait for the local database to be started - - database="$("$phpcli" -f "$dbcheck_php")" - - case "$database" in - "mysql") - CHECK_CMD="$MYSQL_CHECK_CMD" - CHECK_MSG="$MYSQL_CHECK_MSG" - ;; - "pgsql") - CHECK_CMD="$PGSQL_CHECK_CMD" - CHECK_MSG="$PGSQL_CHECK_MSG" - ;; - *) - err 1 "Unknown database configured: $database" - ;; - esac - - for n in $(seq 1 10); do - if $CHECK_CMD > /dev/null 2>&1; then - return - fi - sleep 1 - done - err 1 $CHECK_MSG + wait_for_pids "${pid_daemon}" "${pid_child}" + else + if [ -n "$pid_child" ]; then + echo "${name} not running? (check ${cpidfile})." + else + echo "${name} not running? (check ${pidfile})." + fi fi } diff --git a/www/tt-rss/pkg-plist b/www/tt-rss/pkg-plist index 68506c70ab49..909f900cce5f 100644 --- a/www/tt-rss/pkg-plist +++ b/www/tt-rss/pkg-plist @@ -2373,7 +2373,6 @@ %%WWWDIR%%/themes/night_base.less %%WWWDIR%%/themes/night_blue.css %%WWWDIR%%/themes/night_blue.less -%%WWWDIR%%/ttrss_db_check.php %%WWWDIR%%/utils/phpstan-watcher.sh %%WWWDIR%%/utils/phpunit-integration.sh %%WWWDIR%%/utils/phpunit.sh