From 352c6282410acf1ed99e07b55f1a36474e671f3b Mon Sep 17 00:00:00 2001 From: Tobi DEGNON Date: Mon, 19 Aug 2024 12:51:10 +0100 Subject: [PATCH 1/4] use exec to replace processes --- .../deploy/etc/s6-overlay/s6-rc.d/server/run | 2 +- .../deploy/etc/s6-overlay/s6-rc.d/worker/run | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/{{ cookiecutter.project_name }}/deploy/etc/s6-overlay/s6-rc.d/server/run b/{{ cookiecutter.project_name }}/deploy/etc/s6-overlay/s6-rc.d/server/run index 48d452e..ce92c46 100644 --- a/{{ cookiecutter.project_name }}/deploy/etc/s6-overlay/s6-rc.d/server/run +++ b/{{ cookiecutter.project_name }}/deploy/etc/s6-overlay/s6-rc.d/server/run @@ -1,4 +1,4 @@ #!/command/with-contenv execlineb cd /app -python {{ cookiecutter.project_name }}/__main__.py +exec python {{ cookiecutter.project_name }}/__main__.py diff --git a/{{ cookiecutter.project_name }}/deploy/etc/s6-overlay/s6-rc.d/worker/run b/{{ cookiecutter.project_name }}/deploy/etc/s6-overlay/s6-rc.d/worker/run index 3a61651..f5a23a5 100644 --- a/{{ cookiecutter.project_name }}/deploy/etc/s6-overlay/s6-rc.d/worker/run +++ b/{{ cookiecutter.project_name }}/deploy/etc/s6-overlay/s6-rc.d/worker/run @@ -1,4 +1,4 @@ #!/command/with-contenv execlineb cd /app -python {{ cookiecutter.project_name }}/__main__.py qcluster \ No newline at end of file +exec python {{ cookiecutter.project_name }}/__main__.py qcluster \ No newline at end of file From f21c10f2ec1958cd486ea5eaab1436479805865b Mon Sep 17 00:00:00 2001 From: Tobi DEGNON Date: Mon, 19 Aug 2024 18:54:28 +0100 Subject: [PATCH 2/4] run on the right port (#89) --- .../{{ cookiecutter.project_name }}/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{ cookiecutter.project_name }}/{{ cookiecutter.project_name }}/__main__.py b/{{ cookiecutter.project_name }}/{{ cookiecutter.project_name }}/__main__.py index b5a52b7..2385ecd 100644 --- a/{{ cookiecutter.project_name }}/{{ cookiecutter.project_name }}/__main__.py +++ b/{{ cookiecutter.project_name }}/{{ cookiecutter.project_name }}/__main__.py @@ -47,7 +47,7 @@ def run_gunicorn(argv: list) -> None: gunicorn_args = [ "{{ cookiecutter.project_name }}.wsgi:application", "--bind", - "127.0.0.1:8000", + "127.0.0.1:80", # "unix:/run/{{ cookiecutter.project_name }}.gunicorn.sock", # uncomment this line and comment the line above to use a socket file "--max-requests", "1000", From 8202d5be92c648cd56e4e9ae5b3050c24eac4a04 Mon Sep 17 00:00:00 2001 From: Tobi DEGNON Date: Mon, 19 Aug 2024 20:43:47 +0100 Subject: [PATCH 3/4] bind to all interfaces --- {{ cookiecutter.project_name }}/pyproject.toml | 1 + .../{{ cookiecutter.project_name }}/__main__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/{{ cookiecutter.project_name }}/pyproject.toml b/{{ cookiecutter.project_name }}/pyproject.toml index ec79ee3..d2be9d8 100644 --- a/{{ cookiecutter.project_name }}/pyproject.toml +++ b/{{ cookiecutter.project_name }}/pyproject.toml @@ -185,6 +185,7 @@ extend-ignore = ["TID252", "RUF012", "TRY003", "EM101", "I001", "I002"] [tool.ruff.lint.extend-per-file-ignores] "deploy/*" = ["INP001"] +"*/__main__.py" = [ "S104" ] "*/migrations/*" = ["E501"] "tests/**/*" = ["PLR2004", "S101", "TID252", "ARG001"] "docs/conf.py" = ["INP001", "A001"] diff --git a/{{ cookiecutter.project_name }}/{{ cookiecutter.project_name }}/__main__.py b/{{ cookiecutter.project_name }}/{{ cookiecutter.project_name }}/__main__.py index 2385ecd..fbed8ce 100644 --- a/{{ cookiecutter.project_name }}/{{ cookiecutter.project_name }}/__main__.py +++ b/{{ cookiecutter.project_name }}/{{ cookiecutter.project_name }}/__main__.py @@ -47,7 +47,7 @@ def run_gunicorn(argv: list) -> None: gunicorn_args = [ "{{ cookiecutter.project_name }}.wsgi:application", "--bind", - "127.0.0.1:80", + "0.0.0.0:80", # "unix:/run/{{ cookiecutter.project_name }}.gunicorn.sock", # uncomment this line and comment the line above to use a socket file "--max-requests", "1000", From c1c7127a1225a17168dbebe399e95a7fd32d70b9 Mon Sep 17 00:00:00 2001 From: Tobi DEGNON Date: Tue, 20 Aug 2024 09:53:09 +0100 Subject: [PATCH 4/4] run on expected port for django projects --- {{ cookiecutter.project_name }}/deploy/Dockerfile | 4 ++-- .../{{ cookiecutter.project_name }}/__main__.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/{{ cookiecutter.project_name }}/deploy/Dockerfile b/{{ cookiecutter.project_name }}/deploy/Dockerfile index f1a642d..0fcf7ad 100644 --- a/{{ cookiecutter.project_name }}/deploy/Dockerfile +++ b/{{ cookiecutter.project_name }}/deploy/Dockerfile @@ -50,6 +50,6 @@ COPY {{ cookiecutter.project_name }} /app/{{ cookiecutter.project_name }} COPY manage.py /app/manage.py RUN rm -r /app/{{ cookiecutter.project_name }}/static/ -EXPOSE 80 +EXPOSE 8000 ENTRYPOINT ["/init"] -HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD curl -f http://127.0.0.1:80/health +HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD curl -f http://0.0.0.0:8000/health diff --git a/{{ cookiecutter.project_name }}/{{ cookiecutter.project_name }}/__main__.py b/{{ cookiecutter.project_name }}/{{ cookiecutter.project_name }}/__main__.py index fbed8ce..e394173 100644 --- a/{{ cookiecutter.project_name }}/{{ cookiecutter.project_name }}/__main__.py +++ b/{{ cookiecutter.project_name }}/{{ cookiecutter.project_name }}/__main__.py @@ -47,7 +47,7 @@ def run_gunicorn(argv: list) -> None: gunicorn_args = [ "{{ cookiecutter.project_name }}.wsgi:application", "--bind", - "0.0.0.0:80", + "0.0.0.0:8000", # "unix:/run/{{ cookiecutter.project_name }}.gunicorn.sock", # uncomment this line and comment the line above to use a socket file "--max-requests", "1000",