From 3f3bfcab4c7a24df52ad342556db9cc21b27ef23 Mon Sep 17 00:00:00 2001 From: Jari-Pekka Voutilainen Date: Tue, 27 Aug 2024 12:36:41 +0300 Subject: [PATCH 1/5] decrease harakiri back to 50 --- ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 b/ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 index d6445e05..a2f34a4d 100644 --- a/ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 +++ b/ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 @@ -8,7 +8,7 @@ virtualenv = /usr/lib/ckan/default module = wsgi:application master = true pidfile = /tmp/%n.pid -harakiri = 130 +harakiri = 50 max-requests = 5000 vacuum = true callable = application From eeb91f9477254aa3d4a592372776fee46c249a7a Mon Sep 17 00:00:00 2001 From: Jari-Pekka Voutilainen Date: Tue, 27 Aug 2024 12:36:47 +0300 Subject: [PATCH 2/5] add stats for uwsgitop --- ansible/roles/ckan/tasks/main.yml | 4 ++++ ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 | 2 ++ 2 files changed, 6 insertions(+) diff --git a/ansible/roles/ckan/tasks/main.yml b/ansible/roles/ckan/tasks/main.yml index 050170bb..27d3eec5 100644 --- a/ansible/roles/ckan/tasks/main.yml +++ b/ansible/roles/ckan/tasks/main.yml @@ -205,6 +205,10 @@ group: root mode: 0644 +- name: Install uwsgitop + pip: + name: uwsgitop + - name: Update supervisor configuration shell: supervisorctl update diff --git a/ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 b/ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 index a2f34a4d..5bf004f9 100644 --- a/ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 +++ b/ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 @@ -18,6 +18,8 @@ enable-threads = true reload-on-rss = 2048 processes = 4 threads = 2 +stats = /tmp/stats.sock +memory-report = true cheaper-algo = busyness cheaper = 1 From f1ab70775a80f2d9bcef2058473805c28bdecb65 Mon Sep 17 00:00:00 2001 From: Jari-Pekka Voutilainen Date: Tue, 27 Aug 2024 12:36:53 +0300 Subject: [PATCH 3/5] remove die-on-term --- ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 | 2 -- 1 file changed, 2 deletions(-) diff --git a/ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 b/ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 index 5bf004f9..fb707bbe 100644 --- a/ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 +++ b/ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 @@ -29,8 +29,6 @@ cheaper-step = 1 # Avoid multiple interpreters (automatically created in case you need mounts) single-interpreter = true -# Fix SIGTERM -die-on-term = true # Enable an accept mutex for a more balanced worker load thunder-lock = true From c99c38c4c18261bedea52eca2aa2ece72e519372 Mon Sep 17 00:00:00 2001 From: Jari-Pekka Voutilainen Date: Tue, 27 Aug 2024 12:37:00 +0300 Subject: [PATCH 4/5] remove process groups --- ansible/handlers/handlers.yml | 2 +- ansible/roles/ckan-ui/tasks/main.yml | 2 +- ansible/roles/ckan/tasks/main.yml | 2 +- ansible/roles/ckan/templates/ckan-uwsgi-supervisor.conf.j2 | 5 ----- ansible/roles/postgres/tasks/main.yml | 2 +- 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/ansible/handlers/handlers.yml b/ansible/handlers/handlers.yml index d2b5b07c..252b6f5a 100644 --- a/ansible/handlers/handlers.yml +++ b/ansible/handlers/handlers.yml @@ -7,4 +7,4 @@ service: name=nginx state=restarted - name: Restart CKAN - shell: supervisorctl restart "{{ ckan_supervisor_name }}:*" + shell: supervisorctl restart "{{ ckan_supervisor_name }}" diff --git a/ansible/roles/ckan-ui/tasks/main.yml b/ansible/roles/ckan-ui/tasks/main.yml index 7faa4442..268d587a 100644 --- a/ansible/roles/ckan-ui/tasks/main.yml +++ b/ansible/roles/ckan-ui/tasks/main.yml @@ -10,7 +10,7 @@ shell: lessc "{{ apicatalog_path }}/less/openapi_view.less" "{{ apicatalog_ckanext_path }}/fanstatic/openapi_view.css" - name: Restart CKAN - shell: supervisorctl restart "{{ ckan_supervisor_name }}:*" + shell: supervisorctl restart "{{ ckan_supervisor_name }}" - name: Verify CKAN is running uri: diff --git a/ansible/roles/ckan/tasks/main.yml b/ansible/roles/ckan/tasks/main.yml index 27d3eec5..b311b93f 100644 --- a/ansible/roles/ckan/tasks/main.yml +++ b/ansible/roles/ckan/tasks/main.yml @@ -213,4 +213,4 @@ shell: supervisorctl update - name: Start CKAN - shell: supervisorctl restart "{{ ckan_supervisor_name }}:*" + shell: supervisorctl restart "{{ ckan_supervisor_name }}" diff --git a/ansible/roles/ckan/templates/ckan-uwsgi-supervisor.conf.j2 b/ansible/roles/ckan/templates/ckan-uwsgi-supervisor.conf.j2 index ac47ed7a..8183b4d1 100644 --- a/ansible/roles/ckan/templates/ckan-uwsgi-supervisor.conf.j2 +++ b/ansible/roles/ckan/templates/ckan-uwsgi-supervisor.conf.j2 @@ -2,11 +2,6 @@ command=/usr/lib/ckan/default/bin/uwsgi -i /etc/ckan/default/ckan-uwsgi.ini -; Start just a single worker. Increase this number if you have many or -; particularly long running background jobs. -numprocs=1 -process_name=%(program_name)s-%(process_num)02d - ; Log files - change this to point to the existing CKAN log files stdout_logfile=/var/log/ckan/ckan.log stderr_logfile=/var/log/ckan/ckan.log diff --git a/ansible/roles/postgres/tasks/main.yml b/ansible/roles/postgres/tasks/main.yml index affbdacc..0bc034f3 100644 --- a/ansible/roles/postgres/tasks/main.yml +++ b/ansible/roles/postgres/tasks/main.yml @@ -18,7 +18,7 @@ shell: chmod 600 /var/lib/postgresql/{{ system.postgresql.version }}/main/server.* && chown "postgres:postgres" /var/lib/postgresql/{{ system.postgresql.version }}/main/server.* - name: Ensure CKAN is not running before making changes to the database - supervisorctl: name="{{ ckan_supervisor_name }}:" state=stopped + supervisorctl: name="{{ ckan_supervisor_name }}" state=stopped ignore_errors: True - name: Restart postgres From 8519c34a1ac1bf0889d100994a5447dd2b858131 Mon Sep 17 00:00:00 2001 From: Jari-Pekka Voutilainen Date: Tue, 27 Aug 2024 12:37:52 +0300 Subject: [PATCH 5/5] increase number of threads --- ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 b/ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 index fb707bbe..1ee31561 100644 --- a/ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 +++ b/ansible/roles/ckan/templates/ckan-uwsgi.ini.j2 @@ -17,7 +17,7 @@ strict = true enable-threads = true reload-on-rss = 2048 processes = 4 -threads = 2 +threads = 4 stats = /tmp/stats.sock memory-report = true