-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add resource metrics Add psutil memory info metrics
- Loading branch information
Showing
52 changed files
with
1,602 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
FROM camptocamp/c2cwsgiutils as base-all | ||
LABEL maintainer Camptocamp "info@camptocamp.com" | ||
SHELL ["/bin/bash", "-o", "pipefail", "-cux"] | ||
|
||
# Used to convert the locked packages by poetry to pip requirements format | ||
# We don't directly use `poetry install` because it force to use a virtual environment. | ||
FROM base-all as poetry | ||
|
||
RUN --mount=type=cache,target=/var/lib/apt/lists \ | ||
--mount=type=cache,target=/var/cache,sharing=locked \ | ||
apt-get update \ | ||
&& apt-get install --assume-yes --no-install-recommends python-is-python3 | ||
|
||
# Install Poetry | ||
WORKDIR /tmp | ||
COPY requirements.txt ./ | ||
RUN python3 -m pip install --disable-pip-version-check --requirement=requirements.txt | ||
|
||
# Do the conversion | ||
COPY poetry.lock pyproject.toml ./ | ||
RUN poetry export --output=requirements.txt \ | ||
&& poetry export --with=dev --output=requirements-dev.txt | ||
|
||
# Base, the biggest thing is to install the Python packages | ||
FROM base-all as base | ||
|
||
WORKDIR /app | ||
|
||
EXPOSE 8080 | ||
RUN --mount=type=cache,target=/root/.cache \ | ||
--mount=type=bind,from=poetry,source=/tmp,target=/poetry \ | ||
python3 -m pip install --disable-pip-version-check --no-deps --requirement=/poetry/requirements.txt | ||
|
||
COPY . /app | ||
|
||
ARG GIT_HASH | ||
|
||
RUN --mount=type=cache,target=/root/.cache \ | ||
python3 -m pip install --disable-pip-version-check --no-deps --editable=. \ | ||
&& python3 -m pip freeze > /requirements.txt | ||
RUN ./models_graph.py > models.dot \ | ||
&& ./models_graph.py Hello > models-hello.dot \ | ||
&& c2cwsgiutils-genversion $GIT_HASH \ | ||
&& python3 -m compileall -q . | ||
|
||
ENV \ | ||
DOCKER_RUN=1 \ | ||
DEVELOPMENT=0 \ | ||
SQLALCHEMY_POOL_RECYCLE=30 \ | ||
SQLALCHEMY_POOL_SIZE=5 \ | ||
SQLALCHEMY_MAX_OVERFLOW=25 \ | ||
SQLALCHEMY_SLAVE_POOL_RECYCLE=30 \ | ||
SQLALCHEMY_SLAVE_POOL_SIZE=5 \ | ||
SQLALCHEMY_SLAVE_MAX_OVERFLOW=25 \ | ||
LOG_TYPE=console \ | ||
OTHER_LOG_LEVEL=WARNING \ | ||
GUNICORN_LOG_LEVEL=WARNING \ | ||
SQL_LOG_LEVEL=WARNING \ | ||
C2CWSGIUTILS_LOG_LEVEL=WARNING \ | ||
LOG_LEVEL=INFO | ||
|
||
# www-data | ||
USER 33 | ||
|
||
RUN mkdir -p /prometheus-metrics \ | ||
&& chmod a+rwx /prometheus-metrics | ||
ENV PROMETHEUS_MULTIPROC_DIR=/prometheus-metrics | ||
|
||
CMD ["/venv/bin/gunicorn", "--paste=/app/application.ini"] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
### | ||
# app configuration | ||
# http://docs.pylonsproject.org/projects/pyramid/en/1.6-branch/narr/environment.html | ||
# this file should be used by gunicorn. | ||
### | ||
|
||
[app:app] | ||
use = egg:c2cwsgiutils_app | ||
filter-with = proxy-prefix | ||
|
||
pyramid.reload_templates = %(DEVELOPMENT)s | ||
pyramid.debug_authorization = %(DEVELOPMENT)s | ||
pyramid.debug_notfound = %(DEVELOPMENT)s | ||
pyramid.debug_routematch = %(DEVELOPMENT)s | ||
|
||
pyramid.default_locale_name = en | ||
|
||
sqlalchemy.url = %(SQLALCHEMY_URL)s | ||
sqlalchemy.pool_recycle = %(SQLALCHEMY_POOL_RECYCLE)s | ||
sqlalchemy.pool_size = %(SQLALCHEMY_POOL_SIZE)s | ||
sqlalchemy.max_overflow = %(SQLALCHEMY_MAX_OVERFLOW)s | ||
|
||
sqlalchemy_slave.url = %(SQLALCHEMY_SLAVE_URL)s | ||
sqlalchemy_slave.pool_recycle = %(SQLALCHEMY_SLAVE_POOL_RECYCLE)s | ||
sqlalchemy_slave.pool_size = %(SQLALCHEMY_SLAVE_POOL_SIZE)s | ||
sqlalchemy_slave.max_overflow = %(SQLALCHEMY_SLAVE_MAX_OVERFLOW)s | ||
|
||
c2c.sql_request_id = True | ||
c2c.requests_default_timeout = 2 | ||
|
||
[filter:proxy-prefix] | ||
use = egg:PasteDeploy#prefix | ||
prefix = %(VISIBLE_ENTRY_POINT)s | ||
|
||
[filter:translogger] | ||
use = egg:Paste#translogger | ||
setup_console_handler = False | ||
|
||
[pipeline:main] | ||
pipeline = egg:c2cwsgiutils#client_info egg:c2cwsgiutils#sentry translogger app | ||
|
||
[server:main] | ||
use = egg:waitress#main | ||
listen = *:8080 | ||
threads = %(WAITRESS_THREADS)s | ||
trusted_proxy = True | ||
clear_untrusted_proxy_headers = False | ||
|
||
### | ||
# Logging configuration | ||
# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html | ||
### | ||
|
||
[loggers] | ||
keys = root, guwaitressicorn, sqlalchemy, c2cwsgiutils, c2cwsgiutils_app | ||
|
||
[handlers] | ||
keys = console, json | ||
|
||
[formatters] | ||
keys = generic | ||
|
||
[logger_root] | ||
level = %(OTHER_LOG_LEVEL)s | ||
handlers = %(LOG_TYPE)s | ||
|
||
[logger_waitress] | ||
level = %(WAITRESS_LOG_LEVEL)s | ||
handlers = | ||
qualname = waitress | ||
|
||
# "level = INFO" logs SQL queries. | ||
# "level = DEBUG" logs SQL queries and results. | ||
# "level = WARNING" logs neither. (Recommended for production systems.) | ||
[logger_sqlalchemy] | ||
level = %(SQL_LOG_LEVEL)s | ||
handlers = | ||
qualname = sqlalchemy.engine | ||
|
||
[logger_c2cwsgiutils] | ||
level = %(C2CWSGIUTILS_LOG_LEVEL)s | ||
handlers = | ||
qualname = c2cwsgiutils | ||
|
||
[logger_c2cwsgiutils_app] | ||
level = %(LOG_LEVEL)s | ||
handlers = | ||
qualname = c2cwsgiutils_app | ||
|
||
[handler_console] | ||
class = logging.StreamHandler | ||
kwargs = {'stream': 'ext://sys.stdout'} | ||
level = NOTSET | ||
formatter = generic | ||
|
||
[handler_json] | ||
class = c2cwsgiutils.pyramid_logging.JsonLogHandler | ||
kwargs = {'stream': 'ext://sys.stdout'} | ||
level = NOTSET | ||
formatter = generic | ||
|
||
[formatter_generic] | ||
format = %(levelname)-5.5s %(name)s %(message)s | ||
datefmt = [%Y-%m-%d %H:%M:%S %z] | ||
class = logging.Formatter |
3 changes: 2 additions & 1 deletion
3
...ce_tests/app/c2cwsgiutils_app/__init__.py → ...gunicorn_app/c2cwsgiutils_app/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
acceptance_tests/app/models_graph.py → ...ptance_tests/gunicorn_app/models_graph.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
acceptance_tests/app/scripts/wait-db → ...ptance_tests/gunicorn_app/scripts/wait-db
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.