git: e72b448dc7b2 - 2026Q3 - devel/gitlab-runner: improved start and stop command

Matthias Fechner <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.ports
Message-ID <[email protected]>
The branch 2026Q3 has been updated by mfechner:

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

commit e72b448dc7b210ce42513bf96492e62faa047edd
Author:     Einar Bjarni Halldórsson <[email protected]>
AuthorDate: 2026-07-18 05:48:48 +0000
Commit:     Matthias Fechner <[email protected]>
CommitDate: 2026-07-31 06:51:02 +0000

    devel/gitlab-runner: improved start and stop command
    
    The rc system does not wait till the child terminated.
    Added a logic to wait for parent and child pid to terminate before
    starting it again.
    
    That fixes an issue if gitlab-runner has a long run job active
    while a restart is triggered.
    
    PR:             296226
    (cherry picked from commit 079c83dcc034f2ae7eaf07c140d1204f93e87680)
---
 devel/gitlab-runner/Makefile               |  1 +
 devel/gitlab-runner/files/gitlab_runner.in | 30 ++++++++++++++++++++++++++----
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/devel/gitlab-runner/Makefile b/devel/gitlab-runner/Makefile
index e3cdc26faac1..d6dee5a6ecc7 100644
--- a/devel/gitlab-runner/Makefile
+++ b/devel/gitlab-runner/Makefile
@@ -1,6 +1,7 @@
 PORTNAME=	gitlab-runner
 DISTVERSIONPREFIX=	v
 DISTVERSION=	19.2.0
+PORTREVISION=	1
 CATEGORIES=	devel
 MASTER_SITES=	https://gitlab-runner-downloads.s3.amazonaws.com/master/docker/:dockerx64 \
 		https://gitlab-runner-downloads.s3.amazonaws.com/master/docker/:dockerarm
diff --git a/devel/gitlab-runner/files/gitlab_runner.in b/devel/gitlab-runner/files/gitlab_runner.in
index 48e7caba1c90..d2b1a0fea5f7 100644
--- a/devel/gitlab-runner/files/gitlab_runner.in
+++ b/devel/gitlab-runner/files/gitlab_runner.in
@@ -36,13 +36,15 @@ export HOME=${gitlab_runner_dir}
 export PATH=${PATH}:%%PREFIX%%/bin
 
 pidfile="/var/run/${name}.pid"
+pidfile_child="/var/run/${name}_child.pid"
+
 command="/usr/sbin/daemon"
-command_args="-f -p ${pidfile} env HOME=${gitlab_runner_dir} ${gitlab_runner_env} %%PREFIX%%/bin/gitlab-runner run --syslog --service ${gitlab_runner_syslogtag}"
+command_args="-P ${pidfile} -p ${pidfile_child} -f env HOME=${gitlab_runner_dir} ${gitlab_runner_env} %%PREFIX%%/bin/gitlab-runner run --syslog --service ${gitlab_runner_syslogtag}"
 gitlab_runner_chdir="${gitlab_runner_dir}"
-
-procname=%%PREFIX%%/bin/gitlab-runner
+rc_stop_wait=7200
 
 start_precmd="gitlab_runner_startprecmd"
+stop_cmd="gitlab_runner_stop"
 list_cmd="listfunc"
 register_cmd="registerfunc"
 
@@ -59,12 +61,32 @@ registerfunc()
 gitlab_runner_startprecmd()
 {
         if [ ! -e "${pidfile}" ]; then
-                install -g ${gitlab_runner_group} -o ${gitlab_runner_user} -- /dev/null "${pidfile}";
+                install -g ${gitlab_runner_group} -o ${gitlab_runner_user} -- /dev/null "${pidfile}"
         fi
+	if [ ! -e "${pidfile_child}" ]; then
+		install -g ${gitlab_runner_group} -o ${gitlab_runner_user} -- /dev/null "${pidfile_child}"
+	fi
         if [ ! -d "${gitlab_runner_dir}" ]; then
                 install -d -o "${gitlab_runner_user}" -g "${gitlab_runner_group}" "${gitlab_runner_dir}"
         fi
 }
 
+gitlab_runner_stop()
+{
+	if [ ! -f "${pidfile_child}" ]; then
+		echo "${name} not running"
+		return 0
+	fi
+	child_pid=$(cat ${pidfile_child})
+	if [ -z "${child_pid}" ]; then
+		echo "${name} not running"
+		return 0
+	fi
+	echo "Sending SIGQUIT to gitlab-runner (pid=${child_pid})"
+	kill -QUIT ${child_pid}
+	# Wait for the daemon supervisor to exit, which happens after the child exits
+	wait_for_pids $(cat ${pidfile} 2>/dev/null)
+}
+
 extra_commands="list register"
 run_rc_command $1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.