# HG changeset patch # User drewp@bigasterisk.com # Date 1678758720 25200 # Node ID 5a99bde7a506f36b0216262f205e4d613c92bd4e # Parent 5ad799e534a53c951a8b301d5c454e7bd6b80ad7 stub py service for console diff -r 5ad799e534a5 -r 5a99bde7a506 .hgignore --- a/.hgignore Mon Mar 13 18:50:23 2023 -0700 +++ b/.hgignore Mon Mar 13 18:52:00 2023 -0700 @@ -1,2 +1,3 @@ __pycache__ __pypackages__ +console/node_modules diff -r 5ad799e534a5 -r 5a99bde7a506 .vscode/settings.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.vscode/settings.json Mon Mar 13 18:52:00 2023 -0700 @@ -0,0 +1,8 @@ +{ + "python.analysis.extraPaths": [ + "${workspaceFolder}/__pypackages__/3.10/lib" + ], + "python.autoComplete.extraPaths": [ + "${workspaceFolder}/__pypackages__/3.10/lib" + ] +} \ No newline at end of file diff -r 5ad799e534a5 -r 5a99bde7a506 console/.pdm.toml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/console/.pdm.toml Mon Mar 13 18:52:00 2023 -0700 @@ -0,0 +1,2 @@ +[python] +path = "/usr/bin/python3.10" diff -r 5ad799e534a5 -r 5a99bde7a506 console/Dockerfile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/console/Dockerfile Mon Mar 13 18:52:00 2023 -0700 @@ -0,0 +1,7 @@ +FROM bang5:5000/base_basic + +WORKDIR /opt + +COPY .pdm.toml pdm.lock pyproject.toml ./ +RUN pdm sync + diff -r 5ad799e534a5 -r 5a99bde7a506 console/console.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/console/console.py Mon Mar 13 18:52:00 2023 -0700 @@ -0,0 +1,32 @@ + +import logging +import os +import socket +import sys + +import uvicorn +from prometheus_client import Gauge +from starlette.applications import Starlette +from starlette.requests import Request +from starlette.responses import HTMLResponse +from starlette.routing import Mount +from starlette.staticfiles import StaticFiles +from starlette_exporter import PrometheusMiddleware, handle_metrics + + + + +def main(): + app = Starlette(debug=True, + routes=[ + # Mount('/', app=StaticFiles(directory='.'), name="static"), + ], +) + + app.add_middleware(PrometheusMiddleware, app_name='racc_console') + app.add_route("/metrics", handle_metrics) + uvicorn.run(app, host='0.0.0.0', port=8000) + + +if __name__ == "__main__": + main() \ No newline at end of file diff -r 5ad799e534a5 -r 5a99bde7a506 console/pdm.lock --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/console/pdm.lock Mon Mar 13 18:52:00 2023 -0700 @@ -0,0 +1,125 @@ +# This file is @generated by PDM. +# It is not intended for manual editing. + +[[package]] +name = "anyio" +version = "3.6.2" +requires_python = ">=3.6.2" +summary = "High level compatibility layer for multiple asynchronous event loop implementations" +dependencies = [ + "idna>=2.8", + "sniffio>=1.1", +] + +[[package]] +name = "click" +version = "8.1.3" +requires_python = ">=3.7" +summary = "Composable command line interface toolkit" +dependencies = [ + "colorama; platform_system == \"Windows\"", +] + +[[package]] +name = "colorama" +version = "0.4.6" +requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +summary = "Cross-platform colored terminal text." + +[[package]] +name = "h11" +version = "0.14.0" +requires_python = ">=3.7" +summary = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1" + +[[package]] +name = "idna" +version = "3.4" +requires_python = ">=3.5" +summary = "Internationalized Domain Names in Applications (IDNA)" + +[[package]] +name = "prometheus-client" +version = "0.16.0" +requires_python = ">=3.6" +summary = "Python client for the Prometheus monitoring system." + +[[package]] +name = "sniffio" +version = "1.3.0" +requires_python = ">=3.7" +summary = "Sniff out which async library your code is running under" + +[[package]] +name = "starlette" +version = "0.26.0.post1" +requires_python = ">=3.7" +summary = "The little ASGI library that shines." +dependencies = [ + "anyio<5,>=3.4.0", +] + +[[package]] +name = "starlette-exporter" +version = "0.15.1" +summary = "Prometheus metrics exporter for Starlette applications." +dependencies = [ + "prometheus-client>=0.12", + "starlette", +] + +[[package]] +name = "uvicorn" +version = "0.21.0" +requires_python = ">=3.7" +summary = "The lightning-fast ASGI server." +dependencies = [ + "click>=7.0", + "h11>=0.8", +] + +[metadata] +lock_version = "4.1" +content_hash = "sha256:3b130c72f566859b1db49d162a7f92f47e2dcccf126934033f4857cf83771448" + +[metadata.files] +"anyio 3.6.2" = [ + {url = "https://files.pythonhosted.org/packages/77/2b/b4c0b7a3f3d61adb1a1e0b78f90a94e2b6162a043880704b7437ef297cad/anyio-3.6.2-py3-none-any.whl", hash = "sha256:fbbe32bd270d2a2ef3ed1c5d45041250284e31fc0a4df4a5a6071842051a51e3"}, + {url = "https://files.pythonhosted.org/packages/8b/94/6928d4345f2bc1beecbff03325cad43d320717f51ab74ab5a571324f4f5a/anyio-3.6.2.tar.gz", hash = "sha256:25ea0d673ae30af41a0c442f81cf3b38c7e79fdc7b60335a4c14e05eb0947421"}, +] +"click 8.1.3" = [ + {url = "https://files.pythonhosted.org/packages/59/87/84326af34517fca8c58418d148f2403df25303e02736832403587318e9e8/click-8.1.3.tar.gz", hash = "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e"}, + {url = "https://files.pythonhosted.org/packages/c2/f1/df59e28c642d583f7dacffb1e0965d0e00b218e0186d7858ac5233dce840/click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"}, +] +"colorama 0.4.6" = [ + {url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] +"h11 0.14.0" = [ + {url = "https://files.pythonhosted.org/packages/95/04/ff642e65ad6b90db43e668d70ffb6736436c7ce41fcc549f4e9472234127/h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761"}, + {url = "https://files.pythonhosted.org/packages/f5/38/3af3d3633a34a3316095b39c8e8fb4853a28a536e55d347bd8d8e9a14b03/h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, +] +"idna 3.4" = [ + {url = "https://files.pythonhosted.org/packages/8b/e1/43beb3d38dba6cb420cefa297822eac205a277ab43e5ba5d5c46faf96438/idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"}, + {url = "https://files.pythonhosted.org/packages/fc/34/3030de6f1370931b9dbb4dad48f6ab1015ab1d32447850b9fc94e60097be/idna-3.4-py3-none-any.whl", hash = "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"}, +] +"prometheus-client 0.16.0" = [ + {url = "https://files.pythonhosted.org/packages/5b/8e/6a546e439b4366ab9eab0a736876eb1e1916dd93b4a1fa560ef711d24f8c/prometheus_client-0.16.0-py3-none-any.whl", hash = "sha256:0836af6eb2c8f4fed712b2f279f6c0a8bbab29f9f4aa15276b91c7cb0d1616ab"}, + {url = "https://files.pythonhosted.org/packages/d0/55/9e34c73e1e490b105b4cd13d08497b1f7cb086a260e4161b7b7c2928b196/prometheus_client-0.16.0.tar.gz", hash = "sha256:a03e35b359f14dd1630898543e2120addfdeacd1a6069c1367ae90fd93ad3f48"}, +] +"sniffio 1.3.0" = [ + {url = "https://files.pythonhosted.org/packages/c3/a0/5dba8ed157b0136607c7f2151db695885606968d1fae123dc3391e0cfdbf/sniffio-1.3.0-py3-none-any.whl", hash = "sha256:eecefdce1e5bbfb7ad2eeaabf7c1eeb404d7757c379bd1f7e5cce9d8bf425384"}, + {url = "https://files.pythonhosted.org/packages/cd/50/d49c388cae4ec10e8109b1b833fd265511840706808576df3ada99ecb0ac/sniffio-1.3.0.tar.gz", hash = "sha256:e60305c5e5d314f5389259b7f22aaa33d8f7dee49763119234af3755c55b9101"}, +] +"starlette 0.26.0.post1" = [ + {url = "https://files.pythonhosted.org/packages/53/b7/4a3a1e03c14fd9109e38f3dc89b2446e664543b5f9e5bc0a875af349da15/starlette-0.26.0.post1.tar.gz", hash = "sha256:af0e54d08afed70fcbc53ae01e71c9c62c8ab038ff8cfd3f7477bf0f086b5ab4"}, + {url = "https://files.pythonhosted.org/packages/5b/54/169fef8cf7676c8bd9dbd6af0684eb448cf68ca59ea2979d6a3180ea5ece/starlette-0.26.0.post1-py3-none-any.whl", hash = "sha256:5b80b546ed60d43da45f80113c05ff9f4c44fae95ee884945958eba685c56253"}, +] +"starlette-exporter 0.15.1" = [ + {url = "https://files.pythonhosted.org/packages/0c/28/5ef1e05bd24984d508e93d4a0319b7f63f8ce5d3c33dd1515507c024f76e/starlette_exporter-0.15.1-py3-none-any.whl", hash = "sha256:24eeaef01f05ef973984704427f6e6a93d468f487b8b26ad77548d963affc9fe"}, + {url = "https://files.pythonhosted.org/packages/7c/6d/72fbe02fd9dec57c8990f466255082a26a7b298ccf8a6960f79f3286b746/starlette_exporter-0.15.1.tar.gz", hash = "sha256:3bde5d863effb26684210fe016a1ebf2b383efedf21a4b2f28585ec5064f4033"}, +] +"uvicorn 0.21.0" = [ + {url = "https://files.pythonhosted.org/packages/24/ec/9e3e7c74c342e22dabcf0c6875a40269283f4c8aec2d2f5802b988c570f7/uvicorn-0.21.0-py3-none-any.whl", hash = "sha256:e69e955cb621ae7b75f5590a814a4fcbfb14cb8f44a36dfe3c5c75ab8aee3ad5"}, + {url = "https://files.pythonhosted.org/packages/7e/81/c817246fad66a4e90153f918710d94f422afdc9285cde039cacbb4dccbca/uvicorn-0.21.0.tar.gz", hash = "sha256:8635a388062222082f4b06225b867b74a7e4ef942124453d4d1d1a5cb3750932"}, +] diff -r 5ad799e534a5 -r 5a99bde7a506 console/pyproject.toml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/console/pyproject.toml Mon Mar 13 18:52:00 2023 -0700 @@ -0,0 +1,27 @@ +[project] +name = "" +version = "" +description = "" +authors = [ + {name = "Drew Perttula", email = "drewp@bigasterisk.com"}, +] +dependencies = [ + "starlette>=0.23.1", + "uvicorn>=0.20.0", + + "starlette-exporter>=0.15.1", +] +requires-python = ">=3.10" +license = {text = "MIT"} + + +[tool.pdm] + +[build-system] +requires = ["pdm-pep517>=1.0.0"] +build-backend = "pdm.pep517.api" + +[[tool.pdm.source]] +url = "https://projects.bigasterisk.com/" +verify_ssl = true +name = "home"