Try a different tack...

This commit is contained in:
niten 2023-01-07 14:47:35 -08:00
parent 931c60ee57
commit 00bc4d1da7
2 changed files with 31 additions and 20 deletions

View File

@ -57,15 +57,6 @@ in {
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
reloadIfChanged = true;
path = with pkgs.python310Packages; [
pkgs.python310
gunicorn
fastapi
gunicorn
opencv4
python-multipart
uvicorn
];
environment = {
OBJECTIFIER_YOLOV3_CONFIG = "${pkgs.yolov3-data}/yolov3.cfg";
OBJECTIFIER_YOLOV3_WEIGHTS = "${pkgs.yolov3-data}/yolov3.weights";
@ -74,6 +65,7 @@ in {
OBJECTIFIER_CLEANUP_MAX_AGE = toString cfg.cleanup.max_file_age;
OBJECTIFIER_CLEANUP_DELAY = toString cfg.cleanup.delay;
};
path = [ pkgs.objectifier ];
serviceConfig = {
# PrivateUsers = true;
# PrivateDevices = true;
@ -103,12 +95,10 @@ in {
(map (addr: "--bind ${addr}:${toString cfg.port}")
cfg.listen-addresses);
in (concatStringsSep " " [
"gunicorn"
"objectifier"
bindClause
"--workers ${toString cfg.workers}"
"-k uvicorn.workers.UvicornWorker"
"--pid /run/objectifier.pid"
"objectifier:app"
]);
};
};

View File

@ -1,6 +1,7 @@
{ pkgs, lib, ... }:
pkgs.stdenv.mkDerivation {
let
objectifier-src = pkgs.stdenv.mkDerivation {
name = "objectifier";
src = ./src;
phases = [ "installPhase" ];
@ -9,4 +10,24 @@ pkgs.stdenv.mkDerivation {
cp $src/detector.py $out/detector.py
cp $src/yolo-cli.py $out/objectifier.py
'';
};
pythonYolo = pkgs.python3.withPackages (pyPkgs:
with pyPkgs; [
gunicorn
fastapi
gunicorn
opencv4
python-multipart
uvicorn
]);
in pkgs.writeShellApplication {
name = "objectifier";
runtimeInputs = [ pythonYolo ];
text = pkgs.lib.concatStringsSep " " [
"gunicorn"
"objectifier:app"
"-k uvicorn.workers.UvicornWorker"
''"$@"''
];
}