concat missing environment variables

This commit is contained in:
raf 2023-11-29 04:11:25 +03:00
parent 5c7691ba6b
commit 8426341a37
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
2 changed files with 11 additions and 4 deletions

View file

@ -112,6 +112,10 @@ in {
};
systemd.services."pi-air-quality-monitor" = let
globalEnv = pkgs.writeText "global.env" ''
SERIAL_DEVICE=${cfg.settings.serialPort}
'';
redisEnv = pkgs.writeText "redis.env" ''
REDIS_HOST=${cfg.settings.redis.host}
REDIS_PORT=${toString cfg.settings.redis.port}
@ -125,7 +129,11 @@ in {
Type = "simple";
User = cfg.settings.user;
Group = cfg.settings.group;
EnvironmentFile = [redisEnv] ++ optional (cfg.settings.environmentFile != null) cfg.settings.environmentFile;
EnvironmentFile = lib.concatLists [
[globalEnv]
(optional (cfg.settings.environmentFile != null) [cfg.settings.environmentFile])
(optional cfg.settings.redis.createLocally [redisEnv])
];
WorkingDirectory = "${cfg.settings.dataDir}";
ExecStart = "${lib.getExe cfg.package}";
Restart = "always";

View file

@ -57,18 +57,17 @@ in
log.info("Check if unit is running correctly")
server.wait_for_unit("pi-air-quality-monitor.service")
server.succeed("systemctl status pi-air-quality-monitor.service | grep 'Active: active (running)' >&2")
server.succeed("journalctl -u pi-air-quality-monitor.service >&2")
server.fail("journalctl -u pi-air-quality-monitor.service | grep 'RuntimeError'")
log.info("Showing units content")
server.succeed("systemctl status pi-air-quality-monitor.service >&2")
server.succeed("systemctl cat pi-air-quality-monitor.service >&2")
server.succeed("systemctl cat pi-air-quality-monitor.socket >&2")
log.info("Checking if service is accessible locally")
server.succeed("nc -vz localhost 8080")
client.start()
client.wait_for_unit("default.target")
#client.succeed("nc -vz server 8080")
client.succeed("nc -vz server 8080")
'';
}