Commit 739a637 1 parent 809ce62 commit 739a637 Copy full SHA for 739a637
File tree 2 files changed +13
-6
lines changed
hosts/idols-aquamarine/monitoring
2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -8,11 +8,10 @@ with lib; let
8
8
cfg = config . services . my-victoriametrics ;
9
9
settingsFormat = pkgs . formats . yaml { } ;
10
10
11
- workingDir = "/var/lib/" + cfg . stateDir ;
12
11
startCLIList =
13
12
[
14
13
"${ cfg . package } /bin/victoria-metrics"
15
- "-storageDataPath=${ workingDir } "
14
+ "-storageDataPath=/var/lib/ ${ cfg . stateDir } "
16
15
"-httpListenAddr=${ cfg . listenAddress } "
17
16
"-retentionPeriod=${ cfg . retentionPeriod } "
18
17
]
@@ -133,12 +132,10 @@ in {
133
132
134
133
DynamicUser = true ;
135
134
User = "victoriametrics" ;
136
- Group = "victoriametrics" ;
137
135
RestartSec = 1 ;
138
136
Restart = "on-failure" ;
139
137
RuntimeDirectory = "victoriametrics" ;
140
138
RuntimeDirectoryMode = "0700" ;
141
- WorkingDirectory = workingDir ;
142
139
StateDirectory = cfg . stateDir ;
143
140
StateDirectoryMode = "0700" ;
144
141
Original file line number Diff line number Diff line change 3
3
myvars ,
4
4
...
5
5
} : {
6
+ # Since victoriametrics use DynamicUser, the user & group do not exists before the service starts.
7
+ # this group is used as a supplementary Unix group for the service to access our data dir(/data/apps/xxx)
8
+ users . groups . victoriametrics-data = { } ;
9
+
6
10
# Workaround for victoriametrics to store data in another place
7
11
# https://www.freedesktop.org/software/systemd/man/latest/tmpfiles.d.html#Type
8
12
systemd . tmpfiles . rules = [
9
- "D /data/apps/victoriametrics 0751 victoriametrics victoriametrics - -"
10
- "L+ /var/lib/victoriametrics - - - - /data/apps/victoriametrics"
13
+ "D /data/apps/victoriametrics 0770 root victoriametrics-data - -"
11
14
] ;
12
15
16
+ # Symlinks do not work with DynamicUser, so we should use bind mount here.
17
+ # https://github.com/systemd/systemd/issues/25097#issuecomment-1929074961
18
+ systemd . services . victoriametrics . serviceConfig = {
19
+ SupplementaryGroups = [ "victoriametrics-data" ] ;
20
+ BindPaths = [ "/data/apps/victoriametrics:/var/lib/victoriametrics:rbind" ] ;
21
+ } ;
22
+
13
23
# https://victoriametrics.io/docs/victoriametrics/latest/configuration/configuration/
14
24
services . my-victoriametrics = {
15
25
enable = true ;
You can’t perform that action at this time.
0 commit comments