|
261 | 261 | restartIfChanged = false;
|
262 | 262 | serviceConfig = {
|
263 | 263 | ExecReload = "${lib.getExe' supervisor "supervisorctl"} reload";
|
264 |
| - KillMode = "process"; |
| 264 | + ExecStop = "${lib.getExe' supervisor "supervisorctl"} shutdown"; |
265 | 265 | LimitNOFILE = 1048576;
|
| 266 | + NotifyAccess = "all"; |
266 | 267 | PrivateTmp = "yes";
|
267 | 268 | Restart = "always";
|
268 | 269 | RestartSec = "5s";
|
269 | 270 | SyslogIdentifier = "microvm-virtiofsd@%i";
|
| 271 | + Type = "notify"; |
270 | 272 | WorkingDirectory = "${stateDir}/%i";
|
271 | 273 | };
|
272 |
| - path = with pkgs; [ virtiofsd ]; |
273 | 274 | script = ''
|
274 | 275 | echo "[supervisord]
|
| 276 | + nodaemon=true |
| 277 | + user=root |
| 278 | +
|
| 279 | + [eventlistener:notify] |
| 280 | + command=${pkgs.writers.writePython3 "supervisord-event-handler" { } (lib.readFile ./supervisord-event-handler.py)} |
| 281 | + events=PROCESS_STATE |
275 | 282 | " > /tmp/supervisord.conf
|
276 | 283 |
|
| 284 | + virtiofsd_count=0 |
| 285 | +
|
277 | 286 | for d in $PWD/current/share/microvm/virtiofs/*; do
|
278 | 287 | SOCKET="$(realpath "$(cat $d/socket)")"
|
279 | 288 | SOURCE="$(cat $d/source)"
|
280 | 289 | mkdir -p "$SOURCE"
|
281 | 290 |
|
| 291 | + group_programs+="virtiofsd-$(basename "$d")," |
| 292 | + virtiofsd_count=$((virtiofsd_count+1)) |
| 293 | +
|
282 | 294 | echo "[program:virtiofsd-$(basename "$d")]
|
283 |
| - command=virtiofsd \ |
284 |
| - --socket-path=$SOCKET \ |
285 |
| - --socket-group=${config.users.users.microvm.group} \ |
286 |
| - --shared-dir "$SOURCE" \ |
287 |
| - --rlimit-nofile ${toString serviceConfig.LimitNOFILE} \ |
288 |
| - --thread-pool-size ${toString config.microvm.virtiofsd.threadPoolSize} \ |
289 |
| - --posix-acl --xattr \ |
290 |
| - ${lib.optionalString (config.microvm.virtiofsd.inodeFileHandles != null) |
291 |
| - "--inode-file-handles=${config.microvm.virtiofsd.inodeFileHandles}" |
292 |
| - } \ |
293 |
| - ${lib.concatStringsSep " " config.microvm.virtiofsd.extraArgs} |
294 |
| - " >> /tmp/supervisord.conf |
| 295 | + stderr_syslog=true |
| 296 | + stdout_syslog=true |
| 297 | + command=${lib.getExe pkgs.virtiofsd} \ |
| 298 | + --socket-path=$SOCKET \ |
| 299 | + --socket-group=${config.users.users.microvm.group} \ |
| 300 | + --shared-dir "$SOURCE" \ |
| 301 | + --rlimit-nofile ${toString serviceConfig.LimitNOFILE} \ |
| 302 | + --thread-pool-size ${toString config.microvm.virtiofsd.threadPoolSize} \ |
| 303 | + --posix-acl --xattr \ |
| 304 | + ${lib.optionalString (config.microvm.virtiofsd.inodeFileHandles != null) |
| 305 | + "--inode-file-handles=${config.microvm.virtiofsd.inodeFileHandles}" |
| 306 | + } \ |
| 307 | + ${lib.concatStringsSep " " config.microvm.virtiofsd.extraArgs} |
| 308 | + " >> /tmp/supervisord.conf |
295 | 309 | done
|
296 | 310 |
|
297 |
| - exec ${lib.getExe' supervisor "supervisord"} --nodaemon --user root \ |
298 |
| - --configuration /tmp/supervisord.conf |
| 311 | + echo -n $virtiofsd_count > /tmp/virtiofsd_count |
| 312 | + exec ${lib.getExe' supervisor "supervisord"} --configuration /tmp/supervisord.conf |
299 | 313 | '';
|
300 | 314 | };
|
301 | 315 |
|
|
0 commit comments