I’m looking for library recommendations to do the following:
run Unix processes, redirect and collect their output and status
schedule these processes: some depend on others and thus must run after those that they depend on
run processes in parallel when possible, up to a given upper limit
There are several libraries to run Unix processes but I haven’t seen the part where their dependencies can be expressed. Dune’s fiber sub-system is surely capable of this but I would prefer a dune package when possible. Roughly, this would be equivalent to what can be expressed in a Makefile and using make -p.
The application is to trigger all kinds of ffmpeg video transformation jobs and finally to assemble the resulting video. Each ffmpeg job takes minutes to complete. Obviously I could try to implement this as a Makefile that expresses these dependencies. But at the same time, ffmpeg has complicated command line arguments which I would prefer to assemble in OCaml. I’m currently doing this in Python (without clever scheduling) but would like to do a re-implementation in OCaml. The compromise would be a mixture: implement a driver in OCaml for a single job and task Make with doing the scheduling. I don’t see how systemd would fit in here.
I suppose if you don’t need scheduling in the sense of ‘run this job at a specific time’ then systemd isn’t needed, yes. Generating a Makefile or a ninja file in OCaml seems like a good approach to me. That’s how ReScript (fka BuckleScript) build system works.
That’s similar to what I expect in the neighbor post.
Abstractly, I do need a dependency layer(framework) where I can specify their relation and priority, and there is a low-level running engine whether it’s UNIX processes as you expect or just function applications.
I think you should take a look on minifiber which seems to be what you want . Such small code is widely used on my project when I need true parallelism - of course, I use fork inside…
The code comes from a look on the dune's codebase. It’s not released mostly because I use it only for tests.