|
19 | 19 | microvm.binScripts = lib.mkIf requiresVirtiofsd {
|
20 | 20 | virtiofsd-run =
|
21 | 21 | let
|
22 |
| - supervisordConfig = pkgs.writeText "${config.networking.hostName}-virtiofsd-supervisord.conf" '' |
23 |
| - [supervisord] |
24 |
| - nodaemon=true |
| 22 | + supervisordConfig = { |
| 23 | + supervisord.nodaemon = true; |
25 | 24 |
|
26 |
| - [eventlistener:notify] |
27 |
| - command=${pkgs.writers.writePython3 "supervisord-event-handler" { } ( |
28 |
| - pkgs.substituteAll { |
29 |
| - src = ./supervisord-event-handler.py; |
30 |
| - virtiofsdCount = builtins.length virtiofsShares; |
31 |
| - } |
32 |
| - )} |
33 |
| - events=PROCESS_STATE |
| 25 | + "eventlistener:notify" = { |
| 26 | + command = pkgs.writers.writePython3 "supervisord-event-handler" { } ( |
| 27 | + pkgs.substituteAll { |
| 28 | + src = ./supervisord-event-handler.py; |
| 29 | + virtiofsdCount = builtins.length virtiofsShares; |
| 30 | + } |
| 31 | + ); |
| 32 | + events = "PROCESS_STATE"; |
| 33 | + }; |
| 34 | + } // builtins.listToAttrs ( |
| 35 | + map ({ proto, tag, socket, source, ... }: { |
| 36 | + name = "program:virtiofsd-${tag}"; |
| 37 | + value = { |
| 38 | + stderr_syslog = true; |
| 39 | + stdout_syslog = true; |
| 40 | + autorestart = true; |
| 41 | + command = pkgs.writeShellScript "virtiofsd-${tag}" '' |
| 42 | + if [ $(id -u) = 0 ]; then |
| 43 | + OPT_RLIMIT="--rlimit-nofile 1048576" |
| 44 | + else |
| 45 | + OPT_RLIMIT="" |
| 46 | + fi |
| 47 | + exec ${lib.getExe pkgs.virtiofsd} \ |
| 48 | + --socket-path=${lib.escapeShellArg socket} \ |
| 49 | + --socket-group=${group} \ |
| 50 | + --shared-dir=${lib.escapeShellArg source} \ |
| 51 | + $OPT_RLIMIT \ |
| 52 | + --thread-pool-size ${toString config.microvm.virtiofsd.threadPoolSize} \ |
| 53 | + --posix-acl --xattr \ |
| 54 | + ${lib.optionalString (config.microvm.virtiofsd.inodeFileHandles != null) |
| 55 | + "--inode-file-handles=${config.microvm.virtiofsd.inodeFileHandles}" |
| 56 | + } \ |
| 57 | + ${lib.concatStringsSep " " config.microvm.virtiofsd.extraArgs} |
| 58 | + ''; |
| 59 | + }; |
| 60 | + }) virtiofsShares |
| 61 | + ); |
| 62 | + |
| 63 | + supervisordConfigFile = |
| 64 | + pkgs.writeText "${config.networking.hostName}-virtiofsd-supervisord.conf" ( |
| 65 | + lib.generators.toINI {} supervisordConfig |
| 66 | + ); |
34 | 67 |
|
35 |
| - ${lib.concatMapStrings ({ proto, tag, socket, source, ... }: '' |
36 |
| - [program:virtiofsd-${tag}] |
37 |
| - stderr_syslog=true |
38 |
| - stdout_syslog=true |
39 |
| - autorestart=true |
40 |
| - command=${pkgs.writeShellScript "virtiofsd-${tag}" '' |
41 |
| - if [ $(id -u) = 0 ]; then |
42 |
| - OPT_RLIMIT="--rlimit-nofile 1048576" |
43 |
| - else |
44 |
| - OPT_RLIMIT="" |
45 |
| - fi |
46 |
| - exec ${lib.getExe pkgs.virtiofsd} \ |
47 |
| - --socket-path=${lib.escapeShellArg socket} \ |
48 |
| - --socket-group=${group} \ |
49 |
| - --shared-dir=${lib.escapeShellArg source} \ |
50 |
| - $OPT_RLIMIT \ |
51 |
| - --thread-pool-size ${toString config.microvm.virtiofsd.threadPoolSize} \ |
52 |
| - --posix-acl --xattr \ |
53 |
| - ${lib.optionalString (config.microvm.virtiofsd.inodeFileHandles != null) |
54 |
| - "--inode-file-handles=${config.microvm.virtiofsd.inodeFileHandles}" |
55 |
| - } \ |
56 |
| - ${lib.concatStringsSep " " config.microvm.virtiofsd.extraArgs} |
57 |
| - ''} |
58 |
| - '' ) virtiofsShares} |
59 |
| - ''; |
60 | 68 | in ''
|
61 |
| - exec ${supervisord} --configuration ${supervisordConfig} |
| 69 | + exec ${supervisord} --configuration ${supervisordConfigFile} |
62 | 70 | '';
|
63 | 71 |
|
64 | 72 | virtiofsd-reload = ''
|
|
0 commit comments