Use a pool of detectors.

When more than a single request was coming in at a time, the server
would crash when trying to write the output file. Each worker had a
single detector with one DN network, so if more than <WORKER#> requests
came in at once, one network would be used multiple times--and it's not
threadsafe.

I've added a queue of nets to pull from, so each request has exclusive
access to a specific network.
This commit is contained in:
2023-03-15 12:31:01 -07:00
parent d4de83bf4b
commit ed962240b3
4 changed files with 111 additions and 49 deletions
+14
View File
@@ -36,6 +36,18 @@ in {
default = [ "127.0.0.1" ];
};
pool-size = mkOption {
type = int;
description = "Number of nets to initialize.";
default = 5;
};
detection-timeout = mkOption {
type = int;
description = "Time in seconds to allow for detection to start.";
default = 5;
};
cleanup = {
max_file_age = mkOption {
type = int;
@@ -63,6 +75,8 @@ in {
OBJECTIFIER_BUFFER_SIZE = "524288";
OBJECTIFIER_CLEANUP_MAX_AGE = toString cfg.cleanup.max_file_age;
OBJECTIFIER_CLEANUP_DELAY = toString cfg.cleanup.delay;
OBJECTIFIER_TIMEOUT = toString cfg.detection-timeout;
OBJECTIFIER_POOL_SIZE = toString cfg.pool-size;
};
serviceConfig = {
PrivateUsers = true;