~dricottone/huttese-apk

74654db440b6c77d3fe7141a3d3ad856eb48b683 — Drew DeVault 5 years ago 7c65fd1
todo.sr.ht: normalize init scripts
3 files changed, 31 insertions(+), 26 deletions(-)

M sr.ht/todo.sr.ht/APKBUILD
A sr.ht/todo.sr.ht/todo.sr.ht.confd
R sr.ht/todo.sr.ht/{todo.sr.ht.init => todo.sr.ht.initd}
M sr.ht/todo.sr.ht/APKBUILD => sr.ht/todo.sr.ht/APKBUILD +9 -4
@@ 15,7 15,8 @@ makedepends="py-setuptools nodejs sassc"
subpackages="${pkgname}-openrc"
source="
	$pkgname-$pkgver.tar.gz::https://git.sr.ht/~sircmpwn/$pkgname/archive/$pkgver.tar.gz
	todo.sr.ht.init
	todo.sr.ht.initd
	todo.sr.ht.confd
"
builddir="$srcdir/$pkgname-$pkgver"
export PKGVER=$pkgver


@@ 30,8 31,12 @@ build() {
package() {
	cd "$builddir"
	python3 setup.py install --root="$pkgdir" --optimize=1
	install -Dm755 "$srcdir"/todo.sr.ht.init "$pkgdir"/etc/init.d/todo.sr.ht
	install -Dm755 "$srcdir"/todo.sr.ht.initd \
		"$pkgdir"/etc/init.d/todo.sr.ht
	install -Dm644 "$srcdir"/todo.sr.ht.confd \
		"$pkgdir"/etc/conf.d/todo.sr.ht
}

sha512sums="3f6559de738796ea522fff2ed1aa592bbae4ba56f59535fb66885deb832b5189fd023b108a63427e94128cd5dc71491c76d1e0104b51f20f758bd3fa89168c16  meta.sr.ht-0.9.8.tar.xz
c149ba165ce153a13f55ce4b46427e6a7f7dc97ce7bbd776e6d56255b90edb52cc02f80c83e59dd11a67efd1ef0fe9e2a2812ca171d215df15513a1ca60ba597  meta.sr.ht.init"
sha512sums="5dd2a3cd498f61f67907bb01a18328942e5fad25796648ef71da5bf575dc58e393608165d6476904bd15c95f175a18c2de78253d536ecf3b5c21d4dc48495f13  todo.sr.ht-0.26.3.tar.gz
a7f9c4f821ebca82058b7891722753e57d92a6a0c5e78522c7350c80f292bd2f378b14bdcefd0211dad0933c8fb105617e168596a0a5eda8e46f30406ce52587  todo.sr.ht.initd
a136bda51bef167c90d0c07f158eb24f0e769b5020723cd4ffe49854080540f1e6ac92dbeec469ad124253603dd6f9484c9b7c69c5d406bb1b72e686e775a147  todo.sr.ht.confd"

A sr.ht/todo.sr.ht/todo.sr.ht.confd => sr.ht/todo.sr.ht/todo.sr.ht.confd +14 -0
@@ 0,0 1,14 @@
# Run the daemon as this user:
# TODO_USER=todo

# Bind the web service to this address:
# TODO_BIND=127.0.0.1:5000

# Extra arguments to pass to Gunicorn
# TODO_ARGS=

# If no, use an external postgresql server
# LOCAL_PG=yes

# If no, use an external redis server
# LOCAL_REDIS=yes

R sr.ht/todo.sr.ht/todo.sr.ht.init => sr.ht/todo.sr.ht/todo.sr.ht.initd +8 -22
@@ 1,14 1,18 @@
#!/sbin/openrc-run
name="todo.sr.ht"
description="todo.sr.ht service"

# Override these with /etc/conf.d/todo.sr.ht
supervisor=supervise-daemon
TODO_USER=${TODO_USER:-todo}
TODO_BIND=${TODO_BIND:-127.0.0.1:5000}
TODO_ARGS=${TODO_ARGS:-}
LOCAL_PG=${LOCAL_PG:-yes}
LOCAL_REDIS=${LOCAL_REDIS:-yes}
LOGS=/var/log/todo.sr.ht.log
supervise_daemon_args="-1 $LOGS -2 $LOGS"
command="/usr/bin/gunicorn"
command_args="gitsrht.app:app -b $TODO_BIND $TODO_ARGS"
command_user="$TODO_USER:$TODO_USER"
pidfile="/run/${RC_SVCNAME}.pid"

depend() {
	need net


@@ 16,24 20,6 @@ depend() {
	[ "$LOCAL_PG" = "yes" ] && need postgresql
}

start() {
	ebegin "Starting $name"
	touch "$LOGS"
	chown $TODO_USER "$LOGS"
	start-stop-daemon \
		-u $TODO_USER \
		-1 "$LOGS" \
		-2 "$LOGS" \
		--background \
		--make-pidfile \
		--pidfile /run/$name.pid \
		--exec /usr/bin/gunicorn -- \
			todosrht.app:app -b ${TODO_BIND} ${TODO_ARGS}
	eend $?
}

stop() {
	ebegin "Stopping $name"
	start-stop-daemon --stop --exec /usr/bin/gunicorn --pidfile /run/$name.pid
	eend $?
start_pre() {
	checkpath -f "$LOGS" -m 644 -o "$TODO_USER:$TODO_USER"
}