diff options
Diffstat (limited to 'net-libs/meta-srht')
-rw-r--r-- | net-libs/meta-srht/files/meta.sr.ht-api.confd | 10 | ||||
-rw-r--r-- | net-libs/meta-srht/files/meta.sr.ht-api.initd | 27 | ||||
-rw-r--r-- | net-libs/meta-srht/files/meta.sr.ht-webhooks.confd | 5 | ||||
-rw-r--r-- | net-libs/meta-srht/files/meta.sr.ht-webhooks.initd | 24 | ||||
-rw-r--r-- | net-libs/meta-srht/files/meta.sr.ht.confd | 10 | ||||
-rw-r--r-- | net-libs/meta-srht/files/meta.sr.ht.gunicorn.conf.py | 5 | ||||
-rw-r--r-- | net-libs/meta-srht/files/meta.sr.ht.initd | 33 | ||||
-rw-r--r-- | net-libs/meta-srht/meta-srht-0.63.5.ebuild | 19 | ||||
-rw-r--r-- | net-libs/meta-srht/metadata.xml | 3 |
9 files changed, 105 insertions, 31 deletions
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 } diff --git a/net-libs/meta-srht/meta-srht-0.63.5.ebuild b/net-libs/meta-srht/meta-srht-0.63.5.ebuild index 0a6c975..08bafbb 100644 --- a/net-libs/meta-srht/meta-srht-0.63.5.ebuild +++ b/net-libs/meta-srht/meta-srht-0.63.5.ebuild @@ -15,6 +15,7 @@ LICENSE="AGPL-3" SLOT="0" KEYWORDS="~amd64" RESTRICT="network-sandbox" +IUSE="billing" RDEPEND="" DEPEND="${RDEPEND} @@ -29,6 +30,11 @@ DEPEND="${RDEPEND} dev-python/python-sshpubkeys[${PYTHON_USEDEP}] dev-python/zxcvbn[${PYTHON_USEDEP}] www-servers/gunicorn[${PYTHON_USEDEP}] + + billing? ( + dev-python/stripe + dev-python/weasyprint + ) " BDEPEND="net-libs/nodejs dev-lang/sassc @@ -49,25 +55,32 @@ src_compile() { src_install() { distutils-r1_src_install + dobin "${S}/api/metasrht-api" + dodir "/etc/sr.ht" insinto "/etc/sr.ht/" newins "${S}/config.example.ini" "config.example.meta.sr.ht.ini" + doins "${FIELSDIR}/meta.sr.ht.gunicorn.conf.py" exeinto "/etc/cron.daily" - dobin "${S}/api/metasrht-api" - dodir "/etc/sr.ht" doexe "${FILESDIR}/meta.sr.ht.cron" newinitd "${FILESDIR}/meta.sr.ht.initd" "meta.sr.ht" newconfd "${FILESDIR}/meta.sr.ht.confd" "meta.sr.ht" newinitd "${FILESDIR}/meta.sr.ht-api.initd" "meta.sr.ht-api" newconfd "${FILESDIR}/meta.sr.ht-api.confd" "meta.sr.ht-api" newinitd "${FILESDIR}/meta.sr.ht-webhooks.initd" "meta.sr.ht-webhooks" + newconfd "${FILESDIR}/meta.sr.ht-webhooks.confd" "meta.sr.ht-webhooks" systemd_dounit "${FILESDIR}/meta.sr.ht.service" systemd_dounit "${FILESDIR}/meta.sr.ht-api.service" systemd_dounit "${FILESDIR}/meta.sr.ht-webhooks.service" systemd_dounit "${FILESDIR}/meta.sr.ht-daily.service" systemd_dounit "${FILESDIR}/meta.sr.ht-daily.timer" + + if use billing; then + PYVER="$(python3 --version | cut -d. -f1-2 | cut -d' ' -f2-)" + dodir "/usr/lib/python${PYVER}/site-packages/metasrht/" + touch "/usr/lib/python${PYVER}/site-packages/metasrht/.billing" || die + fi } plg_postinst() { - optfeature "billing support" "dev-python/stripe dev-python/weasyprint" optfeature "daily maintenance" "virtual/cron" } diff --git a/net-libs/meta-srht/metadata.xml b/net-libs/meta-srht/metadata.xml index 83d6e1e..c0b3ccc 100644 --- a/net-libs/meta-srht/metadata.xml +++ b/net-libs/meta-srht/metadata.xml @@ -14,4 +14,7 @@ <doc>https://man.sr.ht/meta.sr.ht/</doc> <remote-id type="sourcehut">meta.sr.ht</remote-id> </upstream> + <use> + <flag name="billing">Extra meta.sr.ht dependencies for billing</flag> + </use> </pkgmetadata> |