我的元数据库服务正在吞噬所有我的机器上的资源,虽然找到了解决方案,但我需要一种方法来限制资源的使用。
我如何在 nixos 上配置它?
❯ nixos-version
22.05.2123.ede02b4ccb1 (Quokka)
我的服务已配置:
systemd.services.metabase = {
description = "Metabase server";
wantedBy = [ "multi-user.target" ];
wants = [ "postgresql.service" "nginx.service" ];
after = [ "network.target" "postgresql.service" ];
environment = {
JAVA_OPTS = "-Dc3p0.maxPoolSize=2 -Xms128m -Xmx1024m";
MB_DB_TYPE = "postgres";
MB_DB_DBNAME="metabase";
MB_DB_HOST="127.0.0.1";
MB_DB_PORT="5432";
MB_DB_USER="postgres";
MB_PLUGINS_DIR = "/var/lib/metabase";
MB_JETTY_HOST = "127.0.0.1";
MB_JETTY_PORT = "3000";
};
serviceConfig = {
DynamicUser = true;
StateDirectory = "/var/lib/metabase";
ExecStart = "${pkgs.metabase}/bin/metabase";
RuntimeMaxSec = 86400;
Restart = "always";
RestartSec = 1;
};
};
答案1
你可以简单地使用systemd资源控制选项在serviceConfig
。