attempt to use memray

This commit is contained in:
Inex Code 2024-11-11 06:23:29 +03:00
parent 4cd90d0c93
commit 1f6a538e9f
4 changed files with 12 additions and 8 deletions

View file

@ -1,4 +1,4 @@
{ pythonPackages, rev ? "local" }: { pythonPackages, rev ? "local", pkgs }:
pythonPackages.buildPythonPackage rec { pythonPackages.buildPythonPackage rec {
pname = "selfprivacy-graphql-api"; pname = "selfprivacy-graphql-api";
@ -22,6 +22,7 @@ pythonPackages.buildPythonPackage rec {
requests requests
websockets websockets
httpx httpx
pkgs.memray
]; ];
pythonImportsCheck = [ "selfprivacy_api" ]; pythonImportsCheck = [ "selfprivacy_api" ];
doCheck = false; doCheck = false;

View file

@ -2,11 +2,11 @@
"nodes": { "nodes": {
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1721949857, "lastModified": 1731295185,
"narHash": "sha256-DID446r8KsmJhbCzx4el8d9SnPiE8qa6+eEQOJ40vR0=", "narHash": "sha256-RaK3jMQ6X8FVESUSURB2An9FYmCfh3nEy8sUyxc/nJk=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "a1cc729dcbc31d9b0d11d86dc7436163548a9665", "rev": "87e3803821210c537acfce075adf5cd030e963b3",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -8,8 +8,9 @@
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
selfprivacy-graphql-api = pkgs.callPackage ./default.nix { selfprivacy-graphql-api = pkgs.callPackage ./default.nix {
pythonPackages = pkgs.python312Packages; pythonPackages = pkgs.python311Packages;
rev = self.shortRev or self.dirtyShortRev or "dirty"; rev = self.shortRev or self.dirtyShortRev or "dirty";
pkgs = pkgs;
}; };
python = self.packages.${system}.default.pythonModule; python = self.packages.${system}.default.pythonModule;
python-env = python-env =
@ -29,6 +30,7 @@
pyflakes pyflakes
typer # for strawberry typer # for strawberry
types-redis # for mypy types-redis # for mypy
pkgs.memray
] ++ strawberry-graphql.optional-dependencies.cli)); ] ++ strawberry-graphql.optional-dependencies.cli));
vmtest-src-dir = "/root/source"; vmtest-src-dir = "/root/source";

View file

@ -45,12 +45,13 @@ in
pkgs.util-linux pkgs.util-linux
pkgs.e2fsprogs pkgs.e2fsprogs
pkgs.iproute2 pkgs.iproute2
pkgs.memray
]; ];
after = [ "network-online.target" ]; after = [ "network-online.target" ];
wantedBy = [ "network-online.target" ]; wantedBy = [ "network-online.target" ];
serviceConfig = { serviceConfig = {
User = "root"; User = "root";
ExecStart = "${selfprivacy-graphql-api}/bin/app.py"; ExecStart = "${pkgs.memray}/bin/memray --trace-python-allocators --live-remote ${selfprivacy-graphql-api}/bin/app.py";
Restart = "always"; Restart = "always";
RestartSec = "5"; RestartSec = "5";
}; };
@ -61,7 +62,7 @@ in
HOME = "/root"; HOME = "/root";
PYTHONUNBUFFERED = "1"; PYTHONUNBUFFERED = "1";
PYTHONPATH = PYTHONPATH =
pkgs.python312Packages.makePythonPath [ selfprivacy-graphql-api ]; pkgs.python311Packages.makePythonPath [ selfprivacy-graphql-api ];
} // config.networking.proxy.envVars; } // config.networking.proxy.envVars;
path = [ path = [
"/var/" "/var/"
@ -82,7 +83,7 @@ in
wantedBy = [ "network-online.target" ]; wantedBy = [ "network-online.target" ];
serviceConfig = { serviceConfig = {
User = "root"; User = "root";
ExecStart = "${pkgs.python312Packages.huey}/bin/huey_consumer.py selfprivacy_api.task_registry.huey"; ExecStart = "${pkgs.python311Packages.huey}/bin/huey_consumer.py selfprivacy_api.task_registry.huey";
Restart = "always"; Restart = "always";
RestartSec = "5"; RestartSec = "5";
}; };