Nix Process Listeners

I run nix mainly to drive my development workflow. I have nix boot up many different services on unique pids and ports what not and they all run parallel to each other, critical for my application.
Many times (unfortunately, thanks nodejs) I have processes die. This causes me to have to kill my entire flow and restart it all, I would rather listen to this event die and have nix restart it on its own.

Anyone have any ideas how I can go upon listening via nix or even outside of nix?

Thanks

Have you considered spawning the services with systemd-run?

1 Like

I haven’t. I’ll need to think of the structure
effectively I have

flake.nix

//callPackage api.nix //nodeJS
//callPackage someGoProject.nix //Golang
//callPackage something.nix //Another service

api.nix
npm run server

then I have a seperate handy tool that reads all of the stdout from all those processes and writes them to the terminal so its all realtime

I’ll have to think of a clever way to
systemd-run npm run server (so to speak)

Thank you

I’ll have to be careful because my continuous integration pipeline really takes advantage of nix here and I’ll have to make sure systemd-run is stable on my virtual machines. Many thoughts but thats a problem for later

Yep, probably not a completely trivial insert, but you could add your own createSystemdRunner that wraps each binary or something. Going to be a heck of a lot easier than implementing all that process management in bash, though.

1 Like