Skip to content

Commit

Permalink
run on different port
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf Grubenmann committed Oct 16, 2023
1 parent 9f1528c commit 97e1892
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
!.git
!.gitignore
!Makefile
!gunicorn.conf.py
.git/config
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var/
*.egg-info/
.installed.cfg
*.egg
.python-version

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN apt-get install --no-install-recommends -y build-essential && \
# time the code changes
# set the BUILD_CORE_SERVICE to non null to install additional service dependencies
ARG BUILD_CORE_SERVICE
COPY pyproject.toml poetry.lock README.rst CHANGES.rst Makefile /code/renku/
COPY pyproject.toml poetry.lock README.rst CHANGES.rst Makefile gunicorn.conf.py /code/renku/
COPY .git /code/renku/.git
COPY renku /code/renku/renku
WORKDIR /code/renku
Expand Down Expand Up @@ -46,6 +46,7 @@ RUN addgroup -gid 1000 shuhitsu && \
if [ -n "${BUILD_CORE_SERVICE}" ]; then mkdir /svc && chown shuhitsu:shuhitsu /svc ; fi

COPY --from=builder /code/renku /code/renku
WORKDIR /code/renku
ENV PATH="${PATH}:/code/renku/.venv/bin"

# shuhitsu (執筆): The "secretary" of the renga, as it were, who is responsible for
Expand All @@ -55,5 +56,6 @@ USER shuhitsu
ENV RENKU_SVC_NUM_WORKERS 4
ENV RENKU_SVC_NUM_THREADS 8
ENV RENKU_DISABLE_VERSION_CHECK=1
ENV PROMETHEUS_MULTIPROC_DIR /tmp

ENTRYPOINT ["tini", "-g", "--", "renku"]
14 changes: 14 additions & 0 deletions gunicorn.conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""Gunicorn Configuration."""
import os

from prometheus_flask_exporter.multiprocess import GunicornPrometheusMetrics


def when_ready(server):
"""Run metrics server on separate port."""
GunicornPrometheusMetrics.start_http_server_when_ready(int(os.getenv("METRICS_PORT", "8765")))


def child_exit(server, worker):
"""Properly exit when metrics server stops."""
GunicornPrometheusMetrics.mark_process_dead_on_child_exit(worker.pid)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ module = [
"pexpect",
"PIL",
"pluggy",
"prometheus_flask_exporter",
"prometheus_flask_exporter.*",
"psutil",
"pyld",
"pyshacl",
Expand Down
2 changes: 2 additions & 0 deletions renku/ui/cli/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def run_api(addr="0.0.0.0", port=8080, timeout=600):
"gunicorn",
"renku.ui.service.entrypoint:app",
loading_opt,
"-c",
"gunicorn.conf.py",
"-b",
f"{addr}:{port}",
"--timeout",
Expand Down
5 changes: 2 additions & 3 deletions renku/ui/service/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import sentry_sdk
from flask import Flask, Response, jsonify, request, url_for
from jwt import InvalidTokenError
from prometheus_flask_exporter import PrometheusMetrics
from prometheus_flask_exporter.multiprocess import GunicornPrometheusMetrics
from sentry_sdk.integrations.flask import FlaskIntegration
from sentry_sdk.integrations.redis import RedisIntegration
from sentry_sdk.integrations.rq import RqIntegration
Expand Down Expand Up @@ -74,8 +74,7 @@ def create_app(custom_exceptions=True):
app.config["MAX_CONTENT_LENGTH"] = MAX_CONTENT_LENGTH

app.config["cache"] = cache
metrics = PrometheusMetrics.for_app_factory()
metrics.init_app(app)
GunicornPrometheusMetrics(app)

build_routes(app)

Expand Down

0 comments on commit 97e1892

Please sign in to comment.