Skip to content

uRadical/mklaunchd

Repository files navigation

mklaunchd

mklaunchd

Generate launchd plists without the friction

mklaunchd is the macOS equivalent of mkunit for systemd. It removes the friction between "I have an idea for a background service" and "it is actually running." Take a Python script, Rust binary, Go service, or bash script and have it running as a launchd background service in under a minute.

mklaunchd creates the file and hands off to standard tooling. After generating a plist it prints the exact launchctl commands for you to run yourself — it does not wrap or replace launchctl.

Install

brew tap uradical/mklaunchd
brew install mklaunchd

Usage

# Generate a plist interactively
mklaunchd generate

# Generate from flags and write
mklaunchd generate \
  --label io.uradical.myservice \
  --binary /usr/local/bin/myservice \
  --scope user-agent \
  --write --yes

# Print to stdout for piping
mklaunchd generate \
  --label io.uradical.myservice \
  --binary /usr/local/bin/myservice \
  --stdout

# Validate plist XML
mklaunchd validate ~/Library/LaunchAgents/io.uradical.myservice.plist

# Run deeper checks
mklaunchd doctor io.uradical.myservice
mklaunchd doctor --all

# Translate an exit code
mklaunchd error 78

After generate writes the plist, mklaunchd prints something like:

✓ Plist written to ~/Library/LaunchAgents/io.uradical.myservice.plist

-- Next steps

  launchctl bootstrap gui/501 ~/Library/LaunchAgents/io.uradical.myservice.plist
  launchctl print gui/501/io.uradical.myservice
  launchctl list | grep io.uradical.myservice

  To stop the service:
  launchctl bootout gui/501/io.uradical.myservice

Plugins

Any executable named mklaunchd-<command> on PATH is automatically available as a subcommand:

brew install yourname/mklaunchd-monitor
mklaunchd monitor io.uradical.myservice

See docs/plugins.md for the plugin authoring guide.

Documentation

man mklaunchd

Or visit uradical.io/tools/mklaunchd.

Build from source

git clone https://github.com/uradical/mklaunchd
cd mklaunchd
make install

Requires macOS 13+ and Xcode 15+.

License

MIT

About

utility to create launchd services on MacOS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors