From c4a94a0f70bcb249bd795b82d4e5a387e5259a17 Mon Sep 17 00:00:00 2001 From: Julien Roy Date: Sat, 7 Jan 2023 23:38:36 -0500 Subject: net-libs/meta-srht: use official RC scripts, update ebuild Signed-off-by: Julien Roy --- net-libs/meta-srht/files/meta.sr.ht-api.confd | 10 +++++-- net-libs/meta-srht/files/meta.sr.ht-api.initd | 27 ++++++++++++------ net-libs/meta-srht/files/meta.sr.ht-webhooks.confd | 5 ++++ net-libs/meta-srht/files/meta.sr.ht-webhooks.initd | 24 ++++++++++------ net-libs/meta-srht/files/meta.sr.ht.confd | 10 +++++-- .../meta-srht/files/meta.sr.ht.gunicorn.conf.py | 5 ++++ net-libs/meta-srht/files/meta.sr.ht.initd | 33 ++++++++++++++++------ 7 files changed, 86 insertions(+), 28 deletions(-) create mode 100644 net-libs/meta-srht/files/meta.sr.ht-webhooks.confd create mode 100644 net-libs/meta-srht/files/meta.sr.ht.gunicorn.conf.py (limited to 'net-libs/meta-srht/files') diff --git a/net-libs/meta-srht/files/meta.sr.ht-api.confd b/net-libs/meta-srht/files/meta.sr.ht-api.confd index 9f22d1f..8dd25e8 100644 --- a/net-libs/meta-srht/files/meta.sr.ht-api.confd +++ b/net-libs/meta-srht/files/meta.sr.ht-api.confd @@ -1,2 +1,8 @@ -ADDRESS=0.0.0.0 -PORT=5100 \ No newline at end of file +# Run the daemon as this user: +# META_USER=meta-srht + +# Bind the API service to this address: +# META_BIND=:5100 + +# Extra arguments to pass to Gunicorn +# META_ARGS= diff --git a/net-libs/meta-srht/files/meta.sr.ht-api.initd b/net-libs/meta-srht/files/meta.sr.ht-api.initd index e3cc759..896a458 100644 --- a/net-libs/meta-srht/files/meta.sr.ht-api.initd +++ b/net-libs/meta-srht/files/meta.sr.ht-api.initd @@ -1,15 +1,26 @@ #!/sbin/openrc-run -# Copyright 2023 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -name="meta.sr.ht API daemon" -description="" +name="meta.sr.ht-api" +description="meta.sr.ht API service" +supervisor=supervise-daemon +META_USER=${META_USER:-meta-srht} +META_BIND=${META_BIND:-:5100} +META_ARGS=${META_ARGS:-} +LOCAL_PG=${LOCAL_PG:-yes} +LOCAL_REDIS=${LOCAL_REDIS:-yes} +LOGS=/var/log/meta.sr.ht-api.log +supervise_daemon_args="-1 $LOGS -2 $LOGS" command="/usr/bin/metasrht-api" -command_args="-b ${ADDRESS}:${PORT}" -command_user="meta-srht:meta-srht" -command_background=true +command_args="-b $META_BIND" +command_user="$META_USER:$META_USER" pidfile="/run/${RC_SVCNAME}.pid" depend() { need net + use redis + use postgresql + use pgbouncer +} + +start_pre() { + checkpath -f "$LOGS" -m 644 -o "$META_USER:$META_USER" } diff --git a/net-libs/meta-srht/files/meta.sr.ht-webhooks.confd b/net-libs/meta-srht/files/meta.sr.ht-webhooks.confd new file mode 100644 index 0000000..809183f --- /dev/null +++ b/net-libs/meta-srht/files/meta.sr.ht-webhooks.confd @@ -0,0 +1,5 @@ +# Run the daemon as this user: +# META_USER=meta-srht + +# Extra arguments to pass to Gunicorn +# META_ARGS= diff --git a/net-libs/meta-srht/files/meta.sr.ht-webhooks.initd b/net-libs/meta-srht/files/meta.sr.ht-webhooks.initd index e9a712f..4f71f13 100644 --- a/net-libs/meta-srht/files/meta.sr.ht-webhooks.initd +++ b/net-libs/meta-srht/files/meta.sr.ht-webhooks.initd @@ -1,15 +1,23 @@ #!/sbin/openrc-run -# Copyright 2023 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -name="meta.sr.ht webhooks daemon" -description="" +name="meta.sr.ht-webhooks" +description="meta.sr.ht webhook delivery service" +supervisor=supervise-daemon +META_USER=${META_USER:-meta-srht} +LOCAL_PG=${LOCAL_PG:-yes} +META_ARGS=${META_ARGS:-} +LOGS=/var/log/meta.sr.ht-webhooks.log +supervise_daemon_args="-1 $LOGS -2 $LOGS" command="/usr/bin/celery" -command_args="-A metasrht.webhooks worker --loglevel=INFO" -command_user="meta-srht:meta-srht" -command_background=true +command_args="-A metasrht.webhooks worker --loglevel=info $META_ARGS" +command_user="$META_USER:$META_USER" pidfile="/run/${RC_SVCNAME}.pid" depend() { need net + use redis + use postgresql +} + +start_pre() { + checkpath -f "$LOGS" -m 644 -o "$META_USER:$META_USER" } diff --git a/net-libs/meta-srht/files/meta.sr.ht.confd b/net-libs/meta-srht/files/meta.sr.ht.confd index 8113c8e..215645f 100644 --- a/net-libs/meta-srht/files/meta.sr.ht.confd +++ b/net-libs/meta-srht/files/meta.sr.ht.confd @@ -1,2 +1,8 @@ -BINDADDRESS=0.0.0.0 -PORT=5000 \ No newline at end of file +# Run the daemon as this user: +# META_USER=meta-srht + +# Bind the API service to this address: +# META_BIND=:5100 + +# Extra arguments to pass to Gunicorn +# META_ARGS= \ No newline at end of file diff --git a/net-libs/meta-srht/files/meta.sr.ht.gunicorn.conf.py b/net-libs/meta-srht/files/meta.sr.ht.gunicorn.conf.py new file mode 100644 index 0000000..aa3e7ae --- /dev/null +++ b/net-libs/meta-srht/files/meta.sr.ht.gunicorn.conf.py @@ -0,0 +1,5 @@ +from prometheus_client import multiprocess + + +def child_exit(server, worker): + multiprocess.mark_process_dead(worker.pid) diff --git a/net-libs/meta-srht/files/meta.sr.ht.initd b/net-libs/meta-srht/files/meta.sr.ht.initd index d1bcc94..8ef4cbb 100644 --- a/net-libs/meta-srht/files/meta.sr.ht.initd +++ b/net-libs/meta-srht/files/meta.sr.ht.initd @@ -1,15 +1,32 @@ #!/sbin/openrc-run -# Copyright 2023 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -name="meta.sr.ht daemon" -description="" +name="meta.sr.ht" +description="meta.sr.ht service" +supervisor=supervise-daemon +META_USER=${META_USER:-meta-srht} +META_BIND=${META_BIND:-127.0.0.1:5000} +META_GUNICORN_CONF=${META_GUNICORN_CONF:-/etc/sr.ht/meta.sr.ht.gunicorn.conf.py} +META_ARGS=${META_ARGS:-} +LOGS=/var/log/meta.sr.ht.log +prometheus_multiproc_dir=/run/meta.sr.ht +supervise_daemon_args="-1 $LOGS -2 $LOGS -e prometheus_multiproc_dir=$prometheus_multiproc_dir" command="/usr/bin/gunicorn" -command_args="metasrht.app:app -b ${ADDRESS}:${PORT}" -command_user="meta-srht:meta-srht" -command_background=true +command_args="metasrht.app:app -b $META_BIND -c $META_GUNICORN_CONF $META_ARGS" +command_user="$META_USER:$META_USER" pidfile="/run/${RC_SVCNAME}.pid" depend() { need net + use redis + use postgresql + use pgbouncer +} + +start_pre() { + checkpath -f "$LOGS" -m 644 -o "$META_USER:$META_USER" + # Workaround for https://github.com/OpenRC/openrc/issues/335 + if [ -n "$prometheus_multiproc_dir" ] + then + checkpath -d "$prometheus_multiproc_dir" -m 775 -o "$META_USER:$META_USER" + rm -rf "$prometheus_multiproc_dir"/* + fi } -- cgit v1.2.3