summaryrefslogtreecommitdiff
path: root/lang/php81/files/php_fpm.in
diff options
context:
space:
mode:
authorMuhammad Moinur Rahman <bofh@FreeBSD.org>2024-07-27 14:13:00 +0200
committerMuhammad Moinur Rahman <bofh@FreeBSD.org>2024-07-27 15:06:58 +0200
commit0f438952da055c26e2b55288f2e406bc5b5e474a (patch)
tree466d8d43586178f4939b5c517c4191a4f369388b /lang/php81/files/php_fpm.in
parentsecurity/rubygem-doorkeeper-rails61: Update version 5.7.0=>5.7.1 (diff)
lang/php81: Fix build with libxml 2.12 and newer
- Rename rc script to comply to the rc scripting recommendations [1] PR: 280153, 280134 [1] Co-authored-by: Alexander Leidinger <netchild@FreeBSD.org> Co-authored-by: Daniel Engberg <diizzy@FreeBSD.org>
Diffstat (limited to 'lang/php81/files/php_fpm.in')
-rw-r--r--lang/php81/files/php_fpm.in102
1 files changed, 102 insertions, 0 deletions
diff --git a/lang/php81/files/php_fpm.in b/lang/php81/files/php_fpm.in
new file mode 100644
index 000000000000..12253b537b2e
--- /dev/null
+++ b/lang/php81/files/php_fpm.in
@@ -0,0 +1,102 @@
+#!/bin/sh
+
+# PROVIDE: php_fpm
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+
+#
+# Add the following line to /etc/rc.conf to enable php-fpm:
+# php_fpm_enable (bool): Set to "NO" by default.
+# Set it to "YES" to enable php-fpm
+# php_fpm_profiles (str): Set to "" by default.
+# Define your profiles here.
+# php_fpm_pid_prefix (str): Set to "" by default.
+# When using profiles manually assign value to "php_fpm_"
+# for prevent collision with other PIDs names.
+
+. /etc/rc.subr
+
+name="php_fpm"
+rcvar=php_fpm_enable
+
+start_precmd="php_fpm_prestart"
+restart_precmd="php_fpm_checkconfig"
+reload_precmd="php_fpm_checkconfig"
+command="%%PREFIX%%/sbin/php-fpm"
+configtest_cmd="php_fpm_checkconfig"
+_pidprefix="/var/run"
+pidfile="${_pidprefix}/php-fpm.pid"
+required_files="%%PREFIX%%/etc/php-fpm.conf"
+
+load_rc_config "${name}"
+
+: ${php_fpm_enable="NO"}
+: ${php_fpm_umask=""}
+: ${php_fpm_svcj_options:="net_basic"}
+
+if [ -n "$2" ]; then
+ profile="$2"
+ if [ "x${php_fpm_profiles}" != "x" ]; then
+ pidfile="${_pidprefix}/${php_fpm_pid_prefix}php-fpm-${profile}.pid"
+ eval php_fpm_configfile="\${php_fpm_${profile}_configfile:-}"
+ if [ "x${php_fpm_configfile}" = "x" ]; then
+ echo "You must define a configuration file (php_fpm_${profile}_configfile)"
+ exit 1
+ fi
+ required_files="${php_fpm_configfile}"
+ eval php_fpm_enable="\${php_fpm_${profile}_enable:-${php_fpm_enable}}"
+ php_fpm_flags="-y ${php_fpm_configfile} -g ${pidfile}"
+ else
+ echo "$0: extra argument ignored"
+ fi
+else
+ if [ "x${php_fpm_profiles}" != "x" -a "x$1" != "x" ]; then
+ for profile in ${php_fpm_profiles}; do
+ echo "===> php_fpm profile: ${profile}"
+ /usr/local/etc/rc.d/php-fpm $1 ${profile}
+ retcode="$?"
+ if [ "0${retcode}" -ne 0 ]; then
+ failed="${profile} (${retcode}) ${failed:-}"
+ else
+ success="${profile} ${success:-}"
+ fi
+ done
+ exit 0
+ fi
+fi
+
+extra_commands="reload configtest logrotate"
+sig_stop="QUIT"
+sig_reload="USR2"
+logrotate_cmd="php_fpm_logrotate"
+
+php_fpm_logrotate() {
+ if [ -z "$rc_pid" ]; then
+ _run_rc_notrunning
+ return 1
+ fi
+ echo "Rotating logs $name."
+ kill -USR1 $rc_pid
+}
+
+php_fpm_checkconfig()
+{
+ echo "Performing sanity check on php-fpm configuration:"
+ eval ${command} ${php_fpm_flags} -t
+}
+
+php_fpm_prestart()
+{
+ php_fpm_checkconfig
+ checkconfig=$?
+ if [ $checkconfig -ne 0 ]; then
+ return $checkconfig
+ fi
+
+ if [ ! -z "$php_fpm_umask" ]; then
+ echo "Setting umask to: ${php_fpm_umask}"
+ umask $php_fpm_umask
+ fi
+}
+
+run_rc_command "$1"