-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagentsview.nix
More file actions
72 lines (69 loc) · 2.13 KB
/
agentsview.nix
File metadata and controls
72 lines (69 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{
config,
pkgs,
...
}: let
port = 8095;
configFile = pkgs.writeText "agentsview-config.toml" ''
[pg]
url = "postgres://agentsview@localhost:5432/agentsview?sslmode=disable"
machine_name = "glyph"
'';
# pg push starts a watcher after syncing; wrap it to exit after sync
pgPushScript = pkgs.writeShellScript "agentsview-pg-push" ''
${pkgs.agentsview}/bin/agentsview pg push &
PID=$!
# Wait for sync to complete, then kill the watcher
sleep 15
kill $PID 2>/dev/null || true
'';
in {
# Serve the aggregated team dashboard from PostgreSQL
systemd.services.agentsview = {
description = "Agentsview team dashboard";
after = ["postgresql.service"];
requires = ["postgresql.service"];
wantedBy = ["multi-user.target"];
serviceConfig = {
ExecStart = "${pkgs.agentsview}/bin/agentsview pg serve -host 127.0.0.1 -port ${toString port}";
DynamicUser = true;
User = "agentsview";
Group = "agentsview";
StateDirectory = "agentsview";
RuntimeDirectory = "agentsview";
Environment = "HOME=/var/lib/agentsview";
ExecStartPre = let
script = pkgs.writeShellScript "agentsview-setup" ''
mkdir -p /var/lib/agentsview/.agentsview
cp ${configFile} /var/lib/agentsview/.agentsview/config.toml
chown -R agentsview:agentsview /var/lib/agentsview/.agentsview
'';
in "+${script}";
Restart = "on-failure";
RestartSec = 5;
};
};
# Push local glyph sessions to PostgreSQL every 10 minutes
systemd.timers.agentsview-pg-push = {
description = "Push agentsview sessions to PostgreSQL";
wantedBy = ["timers.target"];
timerConfig = {
OnBootSec = "2min";
OnUnitActiveSec = "10min";
Persistent = true;
};
};
systemd.services.agentsview-pg-push = {
description = "Push agentsview sessions to PostgreSQL";
after = ["postgresql.service"];
requires = ["postgresql.service"];
serviceConfig = {
Type = "oneshot";
ExecStart = pgPushScript;
User = "mu";
Group = "users";
Environment = "HOME=/home/mu";
TimeoutStartSec = 60;
};
};
}