git: ddd9e80ebb9f - main - devel/forgejo-runner: Add supervisor mode for daemon(8)

From: Vladimir Druzenko <vvd_at_FreeBSD.org>
Date: Sat, 15 Nov 2025 23:58:22 UTC
The branch main has been updated by vvd:

URL: https://cgit.FreeBSD.org/ports/commit/?id=ddd9e80ebb9f5f16bcd3de0d2e43fcf3e1b3f837

commit ddd9e80ebb9f5f16bcd3de0d2e43fcf3e1b3f837
Author:     Vyacheslav <terehovv@mail.ru>
AuthorDate: 2025-11-15 23:54:56 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2025-11-15 23:54:56 +0000

    devel/forgejo-runner: Add supervisor mode for daemon(8)
    
    If the server is not available when act_runner starts, act_runner
    terminates.
    
    Notes:
    1. This is a breaking change - previously set act_runner_flags specified
       in rc.conf are applied to daemon(8), not act_runner. To pass
       parameters to act_runner, act_runner_args is used.
    2. The system must be updated due to FreeBSD-EN-25:06.daemon.
    
    While here fix build with non-default user/group and split long line.
    
    PR:     288957
---
 devel/forgejo-runner/Makefile            | 14 +++++++++-----
 devel/forgejo-runner/files/act_runner.in | 25 ++++++++++++++-----------
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/devel/forgejo-runner/Makefile b/devel/forgejo-runner/Makefile
index e6d42253f9e9..5fd06b3c52e3 100644
--- a/devel/forgejo-runner/Makefile
+++ b/devel/forgejo-runner/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	act_runner
 DISTVERSIONPREFIX=	v
 DISTVERSION=	9.1.0
-PORTREVISION=	4
+PORTREVISION=	5
 CATEGORIES=	devel
 PKGNAMEPREFIX=	forgejo-
 
@@ -28,14 +28,18 @@ LD_FLAG_X_PREFIX=	-X ${GO_MODULE}/internal/pkg/ver
 
 DATADIR=	/var/db/${PORTNAME}
 
-USERS=	${ACT_RUNNER_USER}
-GROUPS=	${ACT_RUNNER_GROUP}
-
 ACT_RUNNER_USER?=	${PORTNAME}
 ACT_RUNNER_GROUP?=	${PORTNAME}
+.if ${ACT_RUNNER_USER} == ${PORTNAME}
+USERS=	${ACT_RUNNER_USER}
+.endif
+.if ${ACT_RUNNER_GROUP} == ${PORTNAME}
+GROUPS=	${ACT_RUNNER_GROUP}
+.endif
 
 post-install:
 	${MKDIR} ${STAGEDIR}${DATADIR} ${STAGEDIR}${ETCDIR}
-	${INSTALL_DATA} ${BUILD_WRKSRC}/internal/pkg/config/config.example.yaml ${STAGEDIR}${ETCDIR}/act_runner.conf.sample
+	${INSTALL_DATA} ${BUILD_WRKSRC}/internal/pkg/config/config.example.yaml \
+		${STAGEDIR}${ETCDIR}/act_runner.conf.sample
 
 .include <bsd.port.mk>
diff --git a/devel/forgejo-runner/files/act_runner.in b/devel/forgejo-runner/files/act_runner.in
index fa243278cc7e..7bb6e2a96978 100644
--- a/devel/forgejo-runner/files/act_runner.in
+++ b/devel/forgejo-runner/files/act_runner.in
@@ -24,17 +24,19 @@ load_rc_config "${name}"
 : ${act_runner_cache_dir:="%%DATADIR%%"}
 : ${act_runner_log_dir:="/var/log/act_runner"}
 : ${act_runner_log_file:="${act_runner_log_dir}/act_runner.log"}
-: ${act_runner_flags:="-c ${act_runner_config} daemon"}
+: ${act_runner_args:="-c ${act_runner_config} daemon"}
 
-procname="%%PREFIX%%/bin/act_runner"
-command="${procname} ${act_runner_flags}"
+command="/usr/sbin/daemon"
 
 pidfile="/var/run/${name}.pid"
+exec_path="%%PREFIX%%/bin/act_runner"
 
-start_cmd="${name}_start"
-sig_stop=KILL
+required_files=${act_runner_config}
 
-act_runner_start() {
+prestart_cmd="${name}_prestart"
+sig_stop=TERM
+
+act_runner_prestart() {
   #  ensure the log directories are owned by the unprivileged user
   for d in "${act_runner_log_dir}"; do
     if [ ! -e "$d" ]; then
@@ -42,11 +44,12 @@ act_runner_start() {
       chown "${act_runner_user}" "$d"
     fi
   done
-  /usr/sbin/daemon -S -l "${act_runner_facility}" -s "${act_runner_priority}" \
-    -T "${name}" \
-    -u "${act_runner_user}" -p "${pidfile}" \
-    -o "${act_runner_log_file}" \
-    $command
 }
 
+command_args=" -r -S -l ${act_runner_facility} -s ${act_runner_priority} \
+    -T ${name} \
+    -u ${act_runner_user} -P ${pidfile} \
+    -o ${act_runner_log_file} \
+    ${exec_path} ${act_runner_args}"
+
 run_rc_command "$1"