Here's a draft of an rc.d script for sthttpd, written with help from Stuart. A few things to note:
The binary is named thttpd, so I used that for the script name too. For those not familiar, sthttpd is an ever-so-lightly patched fork of thttpd. Unless supplied a root directory with the -d flag, thttpd will host the current working directory. That's obviously a problem for an rc.d script. Stuart and I talked for a little while about the best way to do this, and he suggested that I look at /etc/rc.d/amd. I adapted that approach. I thought it was best to stop the process with SIGUSR1, allowing existing connections to complete. Let me know if this could cause unacceptable latency. Looking forward to feedback, Michael Index: Makefile =================================================================== RCS file: /cvs/ports/www/sthttpd/Makefile,v retrieving revision 1.2 diff -u -p -r1.2 Makefile --- Makefile 6 May 2014 09:00:37 -0000 1.2 +++ Makefile 15 Jan 2016 22:55:31 -0000 @@ -3,6 +3,7 @@ COMMENT= tiny/turbo/throttling HTTP server DISTNAME= sthttpd-2.26.4 +REVISION= 0 CATEGORIES= www MASTER_SITES= http://opensource.dyc.edu/pub/sthttpd/ Index: pkg/thttpd.rc =================================================================== RCS file: pkg/thttpd.rc diff -N pkg/thttpd.rc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ pkg/thttpd.rc 15 Jan 2016 22:55:31 -0000 @@ -0,0 +1,21 @@ +#!/bin/sh +# +# $OpenBSD$ + +daemon="${TRUEPREFIX}/sbin/thttpd" + +. /etc/rc.d/rc.subr + +# The /var/www root directory will be overridden by any -d flag the user +# supplies. This addresses the awkward fact that thttpd defaults to the +# current working directory. +rc_start() { + ${rcexec} "cd /var/www; ${pexp}" +} + +# SIGUSR1 allows all existing connections to terminate before exiting. +rc_stop() { + pkill -USR1 -xf "^${pexp}" +} + +rc_cmd $1