Tokio, processes, and systemd namespaces

Hello Rustaceans!

I've got a little app that successfully uses Tokio's Command to run subprocesses and all of that works beautifully. But I'd like to run these in a different systemd slice. I've found crates that work with std:

But is there something that works for Tokio? Or should this be automagically compatible?

The Tokio Command type implements From<std::process::Command>, so if that library is able to construct an std Command object with the desired properties, you can simply convert it to a Tokio command.

2 Likes

That crate seems to work with raw cgroups, not with systemd slices specifically. You'll have to interact with systemd, not just with the kernel's cgroups APIs, if you want that. Furthermore, that crate only seems to support legacy cgroups v1.

Any recommendations?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.