diff --git a/pyproject.toml b/pyproject.toml index a6c2a83..60287e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,10 +10,12 @@ dependencies = [ "parsimonious >=0.10.0, <0.11.0", "flask>=2.2.5", "flask-cors>=5.0.0", + "gunicorn>=23.0.0", ] [project.scripts] run_server = "mtl.run_server:run_server" +run_gunicorn = "mtl.run_gunicorn:run_gunicorn" [build-system] requires = ["uv_build>=0.8.0,<0.9.0", "setuptools", "wheel"] diff --git a/src/mtl/mtl_ast.py b/src/mtl/mtl_ast.py index 0169461..cdc8890 100644 --- a/src/mtl/mtl_ast.py +++ b/src/mtl/mtl_ast.py @@ -10,7 +10,6 @@ from lenses import bind def alw(phi, *, lo=0, hi=float('inf')): - print(type(phi)) return G(Interval(lo, hi), phi) diff --git a/src/mtl/run_gunicorn.py b/src/mtl/run_gunicorn.py new file mode 100644 index 0000000..067b220 --- /dev/null +++ b/src/mtl/run_gunicorn.py @@ -0,0 +1,24 @@ +from gunicorn.app.base import BaseApplication + +class StandaloneApplication(BaseApplication): + def __init__(self, app, options=None): + self.options = options or {} + self.application = app + super().__init__() + + def load_config(self): + for key, value in self.options.items(): + self.cfg.set(key.lower(), value) + + def load(self): + return self.application + +def run_gunicorn(): + from .run_server import app + + options = { + "bind": "127.0.0.1:15478", + "workers": 12, + } + + StandaloneApplication(app, options).run() diff --git a/uv.lock b/uv.lock index d1a2857..95235e9 100644 --- a/uv.lock +++ b/uv.lock @@ -203,6 +203,20 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/e6/c1/8f2c327498b9a15bd7ba426d539760c5ad60b1c1ee8e372bbf43d36f7023/funcy-1.18-py2.py3-none-any.whl", hash = "sha256:00ce91afc850357a131dc54f0db2ad8a1110d5087f1fa4480d7ea3ba0249f89d", size = 33238, upload-time = "2023-01-27T05:45:00.695Z" }, ] +[[package]] +name = "gunicorn" +version = "23.0.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "importlib-metadata", version = "6.7.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.8'" }, + { name = "packaging", version = "24.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.8'" }, + { name = "packaging", version = "25.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.8'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/34/72/9614c465dc206155d93eff0ca20d42e1e35afc533971379482de953521a4/gunicorn-23.0.0.tar.gz", hash = "sha256:f014447a0101dc57e294f6c18ca6b40227a4c90e9bdb586042628030cba004ec", size = 375031, upload-time = "2024-08-10T20:25:27.378Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cb/7d/6dac2a6e1eba33ee43f318edbed4ff29151a49b5d37f080aad1e6469bca4/gunicorn-23.0.0-py3-none-any.whl", hash = "sha256:ec400d38950de4dfd418cff8328b2c8faed0edb0d517d3394e457c317908ca4d", size = 85029, upload-time = "2024-08-10T20:25:24.996Z" }, +] + [[package]] name = "importlib-metadata" version = "6.7.0" @@ -485,6 +499,7 @@ dependencies = [ { name = "flask", version = "3.1.2", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.9'" }, { name = "flask-cors", version = "5.0.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.9'" }, { name = "flask-cors", version = "6.0.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.9'" }, + { name = "gunicorn" }, { name = "lenses" }, { name = "parsimonious" }, ] @@ -495,10 +510,37 @@ requires-dist = [ { name = "discrete-signals", specifier = ">=0.8,<0.9" }, { name = "flask", specifier = ">=2.2.5" }, { name = "flask-cors", specifier = ">=5.0.0" }, + { name = "gunicorn", specifier = ">=23.0.0" }, { name = "lenses", specifier = ">=0.5.0,<0.6.0" }, { name = "parsimonious", specifier = ">=0.10.0,<0.11.0" }, ] +[[package]] +name = "packaging" +version = "24.0" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version < '3.8'", +] +sdist = { url = "https://files.pythonhosted.org/packages/ee/b5/b43a27ac7472e1818c4bafd44430e69605baefe1f34440593e0332ec8b4d/packaging-24.0.tar.gz", hash = "sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9", size = 147882, upload-time = "2024-03-10T09:39:28.33Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/49/df/1fceb2f8900f8639e278b056416d49134fb8d84c5942ffaa01ad34782422/packaging-24.0-py3-none-any.whl", hash = "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5", size = 53488, upload-time = "2024-03-10T09:39:25.947Z" }, +] + +[[package]] +name = "packaging" +version = "25.0" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version >= '3.10'", + "python_full_version == '3.9.*'", + "python_full_version == '3.8.*'", +] +sdist = { url = "https://files.pythonhosted.org/packages/a1/d4/1fc4078c65507b51b96ca8f8c3ba19e6a61c8253c72794544580a7b6c24d/packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f", size = 165727, upload-time = "2025-04-19T11:48:59.673Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/20/12/38679034af332785aac8774540895e234f4d07f7545804097de4b666afd8/packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484", size = 66469, upload-time = "2025-04-19T11:48:57.875Z" }, +] + [[package]] name = "parsimonious" version = "0.10.0"