FreeBSD Bugzilla – Attachment 251515 Details for
Bug 279803
www/tt-rss: Simplify ttrssd rc script
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Simplify ttrssd rc script
0001-www-tt-rss-Simplify-ttrssd-rc-script.patch (text/plain), 7.54 KB, created by
Derek Schrock
on 2024-06-16 23:55:25 UTC
(
hide
)
Description:
Simplify ttrssd rc script
Filename:
MIME Type:
Creator:
Derek Schrock
Created:
2024-06-16 23:55:25 UTC
Size:
7.54 KB
patch
obsolete
>From 00b9d00831165a16c49e03032a6ab3ea614bca44 Mon Sep 17 00:00:00 2001 >From: Derek Schrock <dereks@lifeofadishwasher.com> >Date: Sun, 16 Jun 2024 16:17:32 -0400 >Subject: [PATCH] www/tt-rss: Simplify ttrssd rc script > >Summary: >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. > >Test Plan: >1. service ttrssd status/stop/start while: >- not running >- running > >2. tail logs waiting for the database to start. >- See it fail until the database up > >1. >not running > status: not running > # service ttrssd status > ttrssd is not running. > > stop: not running > # service ttrssd stop > ttrssd not running? (check /var/run/ttrssd.pid). > > start: start > # service ttrssd start > Starting ttrssd. > >running: > status: displays correct pid > # service ttrssd status > ttrssd is running as pid 53703. > # pgrep -fal daemon > 53703 daemon: sh[53731] > 53731 /usr/local/bin/php /usr/local/www/tt-rss/update_daemon2.php > > stop: stops daemon and php process waiting for all childern to finish > # service ttrssd stop > Stopping ttrssd. > Waiting for PIDS: 53703. > # pgrep -fal daemon > # > > start: displays ttrssd is already running > # service ttrssd start > ttrssd already running? (pid=54520). > >2. tailing logs during a failing startup > tail -F /var/log/ttrssd.log > <pre>Exception while creating PDO object:SQLSTATE[08006] [7] connection to server at ".... failed: Connection refused > Is the server running on that host and accepting TCP/IP connections?... : Connection refused > ... > [21:26:31/54736] Lock: update.lock > [21:26:31/54736] Database schema is already at latest version. > [21:26:32/54735] Installing shutdown handlers > [21:26:32/54735] Spawned child process with PID 54739 for task 0. > ... > >One issue noticed with daemon is it can't be killed by normal means (service ttrssd stop) if the child process isn't running. I believe this is the cause of the issue? https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277959 If the rc script needs to handle this I beleive I can add a prestop checking if `pgrep -P <parent>` return value and killing the parent and deleting the pid file. > >Differential Revision: https://reviews.freebsd.org/D45618 >--- > www/tt-rss/Makefile | 6 +- > www/tt-rss/files/ttrss_db_check.php.in | 8 --- > www/tt-rss/files/ttrssd.in | 88 +++----------------------- > www/tt-rss/pkg-plist | 1 - > 4 files changed, 10 insertions(+), 93 deletions(-) > delete mode 100644 www/tt-rss/files/ttrss_db_check.php.in > >diff --git a/www/tt-rss/Makefile b/www/tt-rss/Makefile >index d3e5cc1029..d3230ba041 100644 >--- a/www/tt-rss/Makefile >+++ b/www/tt-rss/Makefile >@@ -16,7 +16,7 @@ RUN_DEPENDS= ${LOCALBASE}/bin/git:devel/git > USES= gettext-tools php:cli,web,flavors shebangfix > > USE_GITLAB= yes >-GL_SITE= https://gitlab.tt-rss.org >+GL_SITE= https://gitlab.tt-rss.org/tt-rss/tt-rss > GL_TAGNAME= d832907125a7711397da8ade5cfb51082d802542 > # phe json/openssl extension is required but it's statically linked in default php > USE_PHP= ctype dom exif fileinfo filter iconv intl mbstring pcntl pdo \ >@@ -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/files/ttrss_db_check.php.in b/www/tt-rss/files/ttrss_db_check.php.in >deleted file mode 100644 >index cbc7aaac88..0000000000 >--- 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 a92d4464df..b8712ee08e 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,86 +18,18 @@ 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" >-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 >- >-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?" >- >-ttrssd_start() { >- if ! [ -x $phpcli ]; then >- echo "$phpcli not found" >- exit 1 >- fi >- >- if [ -f $pidfile ]; then >- echo "$name already running?" >- exit 2 >- fi >- >- 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" >-} >- >-ttrssd_stop() { >- if ! [ -f $pidfile ]; then >- echo "$name not running?" >- exit 1 >- fi >- >- echo "Stopping $long_name" >- pkill -CHLD -F "$pidfile" >- pkill -F "$pidfile" >- pwait "$(cat $ppidfile)" >-} >- >-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 >- fi >-} >+command="/usr/sbin/daemon" >+command_args="-rR 10 -H -P $pidfile -u %%WWWOWN%% \ >+ -o $ttrssd_log sh -c \ >+ '$initdb_php --update-schema=force-yes; $phpupd'" > > run_rc_command "$1" >diff --git a/www/tt-rss/pkg-plist b/www/tt-rss/pkg-plist >index 68506c70ab..909f900cce 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 >-- >2.45.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 279803
:
251515
|
251582
|
251586