Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Mar 2019 08:52:34 +0000 (UTC)
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r496319 - in head/www/kcgi: . files
Message-ID:  <201903200852.x2K8qYOD045681@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bapt
Date: Wed Mar 20 08:52:34 2019
New Revision: 496319
URL: https://svnweb.freebsd.org/changeset/ports/496319

Log:
  Add a rc script
  
  Add a rc script (with profile support) to allow users to use kfcgi so spawn fcgi
  processes
  
  Submitted by:	Causal Agent <june@causal.agency>

Added:
  head/www/kcgi/files/kfcgi.in   (contents, props changed)
Modified:
  head/www/kcgi/Makefile

Modified: head/www/kcgi/Makefile
==============================================================================
--- head/www/kcgi/Makefile	Wed Mar 20 08:39:43 2019	(r496318)
+++ head/www/kcgi/Makefile	Wed Mar 20 08:52:34 2019	(r496319)
@@ -2,6 +2,7 @@
 
 PORTNAME=	kcgi
 PORTVERSION=	0.10.10
+PORTREVISION=	1
 CATEGORIES=	www devel
 MASTER_SITES=	http://kristaps.bsd.lv/kcgi/snapshots/
 
@@ -16,6 +17,7 @@ OPTIONS_DEFINE=	EXAMPLES
 
 HAS_CONFIGURE=	yes
 MAKE_ARGS=	DATADIR=${EXAMPLESDIR}
+USE_RC_SUBR=	kfcgi
 
 post-patch:
 	@${REINPLACE_CMD} -e "s/install -m 0555/${INSTALL_PROGRAM}/" \

Added: head/www/kcgi/files/kfcgi.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/www/kcgi/files/kfcgi.in	Wed Mar 20 08:52:34 2019	(r496319)
@@ -0,0 +1,73 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+# PROVIDE: kfcgi
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf to enable kfcgi:
+#
+# kfcgi_enable="YES"
+#
+# Use kfcgi_prog to set the worker process of kfcgi.
+#
+# The kfcgi rc.d script supports multiple profiles. When profiles are
+# specified, the non-profile-specific parameters become defaults.
+#
+# Example:
+#
+# kfcgi_enable="YES"
+# kfcgi_profiles="server1 server2"
+# kfcgi_server1_flags="-s /var/run/kfcgi.server1.sock"
+# kfcgi_server1_prog="/usr/local/bin/server1prog"
+# kfcgi_server2_flags="-s /var/run/kfcgi.server2.sock"
+# kfcgi_server2_prog="/usr/local/bin/server2prog"
+
+. /etc/rc.subr
+
+name="kfcgi"
+rcvar="kfcgi_enable"
+
+load_rc_config $name
+
+: ${kfcgi_enable:="NO"}
+
+procname="%%PREFIX%%/sbin/${name}"
+command="/usr/sbin/daemon"
+pidprefix="/var/run/${name}"
+pidfile="${pidprefix}.pid"
+
+if [ -n "$2" ]; then
+	profile="$2"
+	if [ -n "${kfcgi_profiles}" ]; then
+		pidfile="${pidprefix}.${profile}.pid"
+		eval kfcgi_enable="\${kfcgi_${profile}_enable:-${kfcgi_enable}}"
+		eval kfcgi_flags="\${kfcgi_${profile}_flags:-${kfcgi_flags}}"
+		eval kfcgi_prog="\${kfcgi_${profile}_prog:-${kfcgi_prog}}"
+	else
+		echo "$0: extra argument ignored"
+	fi
+else
+	if [ -n "${kfcgi_profiles}" -a -n "$1" ]; then
+		for profile in ${kfcgi_profiles}; do
+			echo "===> kfcgi profile: ${profile}"
+			%%PREFIX%%/etc/rc.d/kfcgi $1 ${profile}
+			retcode="$?"
+			if [ "0${retcode}" -ne 0 ]; then
+				failed="${profile} (${retcode}) ${failed:-}"
+			else
+				success="${profile} ${success:-}"
+			fi
+		done
+		exit 0
+	fi
+fi
+
+# run_rc_command would send ${name}_flags as parameters to $command (daemon).
+# This ensures they are actually passed to kfcgi instead.
+actual_kfcgi_flags="${kfcgi_flags}"
+kfcgi_flags=""
+command_args="-f -p ${pidfile} -- ${procname} -d ${actual_kfcgi_flags} -- ${kfcgi_prog}"
+
+run_rc_command "$1"



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