diff options
author | davidovski <david@davidovski.xyz> | 2022-08-29 13:01:02 +0000 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2022-08-29 13:01:02 +0000 |
commit | c38dfe6188112ca490090966a63faefe5ec7e9a0 (patch) | |
tree | 0b5cb4f2b5148784d852070317d90485ab31e122 /repo/php8/php8-fpm.initd | |
parent | 49fa1762a5c52ff2cf981f29a45e1797e3885bb4 (diff) |
added snes9x and php
Diffstat (limited to 'repo/php8/php8-fpm.initd')
-rw-r--r-- | repo/php8/php8-fpm.initd | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/repo/php8/php8-fpm.initd b/repo/php8/php8-fpm.initd new file mode 100644 index 0000000..f498581 --- /dev/null +++ b/repo/php8/php8-fpm.initd @@ -0,0 +1,93 @@ +#!/sbin/openrc-run + +# If you want to run separate master process per pool, then create a symlink +# to this runscript for each pool. In that mode, the php-fpm daemon is started +# as nobody by default. You can override the user (and group) by declaring +# variable "user" and optionally "group" in conf.d file, or in the $fpm_config +# file (the former has precedence). + +: ${name:="PHP FastCGI Process Manager"} + +command="/usr/sbin/php-fpm8" +command_background="yes" +start_stop_daemon_args="--quiet" +pidfile="/run/$RC_SVCNAME/php-fpm.pid" +retry="SIGTERM/20" + +# configtest is here only for backward compatibility +extra_commands="checkconfig configtest" +extra_started_commands="reload reopen" +description_checkconfig="Run php-fpm config check" +description_reload="Gracefully reload workers and config" +description_reopen="Reopen log files" + +required_files="$fpm_config" + +depend() { + need net + use apache2 lighttpd nginx +} + +init_vars() { + # Defaults for single master process with multiple pools + if [ "$RC_SVCNAME" = "php-fpm8" ]; then + : ${fpm_config:="/etc/php8/php-fpm.conf"} + : ${user:="root"} + # Defaults for master process per pool + else + : ${fpm_config="/etc/php8/php-fpm.d/${RC_SVCNAME#php-fpm8.}.conf"} + : ${user:="$(conf_get user)"} + : ${user:="nobody"} + : ${group:="$(conf_get group)"} + fi + command_args="--nodaemonize --fpm-config $fpm_config" + start_stop_daemon_args="$start_stop_daemon_args + --user $user ${group:+"--group $group"}" +} + +start_pre() { + checkconfig || return 1 + + # If unix socket is used (instead of TCP/IP), then ensure that the + # directory exists and has correct privileges. + local listen="$(conf_get listen)" + if [ "${listen:0:1}" = "/" ]; then + checkpath -d -o $user:$group "$(dirname "$listen")" + fi + + checkpath -d "$(dirname "$pidfile")" +} + +reload() { + ebegin "Reloading $name" + start-stop-daemon --signal USR2 --pidfile "$pidfile" + eend $? +} + +reopen() { + ebegin "Reopening $name log files" + start-stop-daemon --signal USR1 --pidfile "$pidfile" + eend $? +} + +checkconfig() { + init_vars + ebegin "Checking $fpm_config" + + local out + out="$(su -s /bin/sh -c "$command --test --fpm-config $fpm_config" $user 2>&1)" || { + printf "%s\n" "$out" + eend 1 "failed, please correct errors above" + return 1 + } +} + +configtest() { + ewarn "configtest is deprecated, use checkconfig instead" + checkconfig +} + +conf_get() { + local key="$1" + sed -nE "s/^${key}\s*=\s*\"?([^\";]+).*/\1/p" "$fpm_config" | head -n 1 +} |