1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-15 12:15:22 +03:00
aports/community/thttpd/thttpd.initd
Jakub Jirutka 3951767dcb community/thttpd: allow to disable logging debug messages to syslog
I use thttpd for exposing Prometheus metrics using CGI script. Now it
logs "spawned CGI process ..." to syslog each time the metrics endpoint
is requested which fills /var/log/messages.
2025-04-25 19:41:24 +00:00

51 lines
948 B
Bash

#!/sbin/openrc-run
name=thttpd
description="tiny/turbo/throttling HTTP server"
extra_started_commands="reopen stats"
description_reopen="Reopen log file"
description_stats="Dump statistics to syslog"
: ${cfgfile:=/etc/$RC_SVCNAME.conf}
command=/usr/sbin/thttpd
command_args="-D -C $cfgfile $command_args"
command_background=yes
pidfile="/run/$RC_SVCNAME.pid"
required_files="$cfgfile"
depend() {
need net
after firewall
}
start_pre() {
# This works only in Alpine's thttpd.
if ! yesno "${log_debug:-yes}"; then
export THTTPD_LOG_DEBUG=0
fi
}
reopen() {
ebegin "Reopening $name log file"
if [ "$supervisor" ]; then
$supervisor "$RC_SVCNAME" --signal HUP
else
start-stop-daemon --signal HUP --pidfile "$pidfile"
fi
eend $?
}
stats() {
ebegin "Dump $name statistics to syslog"
if [ "$supervisor" ]; then
$supervisor "$RC_SVCNAME" --signal USR2
else
start-stop-daemon --signal USR2 --pidfile "$pidfile"
fi
eend $?
}