Launchctl
Tiny Rust wrapper library for MacOS service launcher launchctl
. This library
offers a more intuitive interface for managing services on MacOS. Other Rust
crates exist for interfacing with cross platform launch services. This library
is specifically for MacOS. For more info about launchctl
and launchd
see
the official apple docs.
[!TIP]
launchctl
is the best way to make lightweight daemons, use this crate to throw up background jobs with ease! When combined with cli options it is easy and safe to stop and start jobs.
### Usage
The Service struct is the main entrypoint of this library. It uses a `bon` builder.
```rust
fn main() {
// basic construction of a service
let basic_service = Service::builder()
.name("com.<owner name>.<binary name>")
.build();
// more advanced construction of a service
let more_custom = Service::builder()
.name("com.<owner name>.<binary name>")
.
.build();
// create a .plist file for the service
// ...
basic.start().unwrap();
custom.stop().unwrap();
}
Limitations
Currently this crate does not support creating or modifying plist files. There are other crates that can give you this behavior https://github.com/koenichiwa/launchd, or you can hard code them as strings which is what I prefer.
Here is an example of how I do that in my srhd crate.
Contribution
Bro I love when people contribute or even submit issues. It's good for everyone's career and understanding of everything, by all means open an issue or a PR!