Skip to content

Commit b0de9a7

Browse files
Troubleshoot dysfunctional presenters (#3371)
1 parent 07462dc commit b0de9a7

File tree

5 files changed

+35
-1
lines changed

5 files changed

+35
-1
lines changed

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ check-initial-data-json:
7575
check-example-data-json:
7676
python cli/check_json.py data/example-data.json
7777

78+
# The commands below can be called in the container to open the gunicorn control socket interfaces
79+
# for the action and presenter services respectively.
80+
# Environment setting OPENSLIDES_BACKEND_ENABLE_CONTROL_SOCKET needs to be true for this to be possible.
81+
82+
open-gunicornc-action:
83+
gunicornc -s "openslides-action.ctl"
84+
85+
open-gunicornc-presenter:
86+
gunicornc -s "openslides-presenter.ctl"
87+
7888

7989

8090
########################## Deprecation List ##########################

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ The action component listens to port 9002. The presenter component listens to po
116116

117117
If `OPENSLIDES_BACKEND_CREATE_INITIAL_DATA` is true, use the password in the given file as the password for the user with id `1`. Only applicable in productive mode. Default: `/run/secrets/superadmin`
118118

119+
* `OPENSLIDES_BACKEND_ENABLE_CONTROL_SOCKET`
120+
121+
If `OPENSLIDES_BACKEND_ENABLE_CONTROL_SOCKET` is true, the backend will generate a gunicorn control interface server for both actions (`openslides-action.ctl`) and presenters (`openslides-presenter.ctl`). This will make it possible to observe how many web workers there are and some other actions by calling `gunicornc -s <control interface name>`, `make open-gunicornc-action`, or `make open-gunicornc-presenter` in the backend container, see [the gunicorn guides](https://gunicorn.org/guides/gunicornc/) for usage information.
122+
119123
### Development
120124

121125
* `OPENSLIDES_DEVELOPMENT`

openslides_backend/main.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from openslides_backend.shared.interfaces.env import Env
1313

1414
from .action.action_worker import gunicorn_post_request, gunicorn_worker_abort
15-
from .shared.env import Environment
15+
from .shared.env import Environment, is_truthy
1616
from .shared.interfaces.wsgi import WSGIApplication
1717

1818
# register_services()
@@ -60,10 +60,21 @@ def load_config(self) -> None:
6060
), # Threads per Worker(process)
6161
"post_request": gunicorn_post_request,
6262
"worker_abort": gunicorn_worker_abort,
63+
"control_socket_disable": not is_truthy(
64+
self.env.OPENSLIDES_BACKEND_ENABLE_CONTROL_SOCKET
65+
),
66+
"control_socket": self.get_control_socket_name(),
6367
}
6468
for key, value in options.items():
6569
self.cfg.set(key, value)
6670

71+
def get_control_socket_name(self) -> str:
72+
if self.view_name == "ActionView":
73+
return "openslides-action.ctl"
74+
elif self.view_name == "PresenterView":
75+
return "openslides-presenter.ctl"
76+
raise ValueError(f"Invalid view {self.view_name}")
77+
6778
def get_address(self) -> str:
6879
if self.view_name == "ActionView":
6980
return f"0.0.0.0:{self.env.ACTION_PORT}"

openslides_backend/shared/env.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class Environment(Env):
3939
"OPENSLIDES_BACKEND_WORKER_TIMEOUT": "30",
4040
"OPENSLIDES_BACKEND_THREAD_WATCH_TIMEOUT": "1",
4141
"OPENSLIDES_BACKEND_CREATE_INITIAL_DATA": "false",
42+
"OPENSLIDES_BACKEND_ENABLE_CONTROL_SOCKET": "false",
4243
"SUPERADMIN_PASSWORD_FILE": "/run/secrets/superadmin",
4344
"OPENSLIDES_DEVELOPMENT": "false",
4445
"OPENSLIDES_LOGLEVEL": Loglevel.NOTSET.name,

tests/system/presenter/test_get_user_related_models.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ def test_get_user_related_models_simple(self) -> None:
5555
}
5656
}
5757

58+
def test_get_user_related_models_no_info(self) -> None:
59+
bob_id = self.create_user("bob")
60+
status_code, data = self.request(
61+
"get_user_related_models", {"user_ids": [bob_id]}
62+
)
63+
self.assertEqual(status_code, 200)
64+
assert data == {"2": {}}
65+
5866
def test_get_user_related_models_committee(self) -> None:
5967
self.set_models(
6068
{

0 commit comments

Comments
 (0)