diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md index e4e3743bb1..9cc0ec23a3 100644 --- a/docs/Formula-Cookbook.md +++ b/docs/Formula-Cookbook.md @@ -871,11 +871,16 @@ Another example would be configuration files that should not be overwritten on p There are two ways to add `launchd` plists and `systemd` services to a formula, so that [`brew services`](https://github.com/Homebrew/homebrew-services) can pick them up: -1. If the package already provides a service file the formula can install it into the prefix: +1. If the package already provides a service file the formula can reference it by name: ```ruby - prefix.install_symlink "file.plist" => "#{plist_name}.plist" - prefix.install_symlink "file.service" => "#{service_name}.service" + service do + # Corresponds to the launchd script at "#{plist_name}.plist". + plist_name "custom.plist.name" + + # Corresponds to the systemd script at "#{service_name}.service". + service_name "custom.service.name" + end ``` 2. If the formula does not provide a service file you can generate one using the following stanza: @@ -888,7 +893,7 @@ There are two ways to add `launchd` plists and `systemd` services to a formula, #### Service block methods -This table lists the options you can set within a `service` block. Only the `run` field is required which indicates what to run. +This table lists the options you can set within a `service` block. One of the `run`, `plist_name` or `service_name` fields is required inside the service block. The `run` field indicates what command to run and is required before using fields other than `plist_name` and `service_name`. | method | default | macOS | Linux | description | | ----------------------- | ------------ | :---: | :---: | ----------- | @@ -909,6 +914,8 @@ This table lists the options you can set within a `service` block. Only the `run | `process_type` | - | yes | no-op | type of process to manage: `:background`, `:standard`, `:interactive` or `:adaptive` | `macos_legacy_timers` | - | yes | no-op | timers created by `launchd` jobs are coalesced unless this is set | `sockets` | - | yes | no-op | socket that is created as an accesspoint to the service +| `plist_name` | `"homebrew.mxcl.#{formula.name}"` | yes | no | name of the `launchd` job +| `service_name` | `"homebrew.#{formula.name}"` | no | yes | name of the `systemd` job For services that are kept alive after starting you can use the default `run_type`: