Skip to content

Commit b8f6558

Browse files
authored
Correct launchctl commands for MacOS agent management (#4833)
1 parent e5ed568 commit b8f6558

3 files changed

Lines changed: 38 additions & 41 deletions

File tree

docs/manage/reference/viam-agent/manage-viam-agent.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,45 @@ You can only restore this file if you have access to the machine configuration.
106106
sudo launchctl kickstart system/com.viam.agent
107107
```
108108

109+
If the service fails to start, make sure it is bootstrapped. The following command will
110+
print an error message if the service is NOT bootstrapped.
111+
112+
```sh {class="command-line" data-prompt="$"}
113+
sudo launchctl print system/com.viam.agent
114+
```
115+
116+
The following command will bootstrap the service.
117+
118+
```sh {class="command-line" data-prompt="$"}
119+
sudo launchctl bootstrap system /Library/LaunchDaemons/com.viam.agent.plist
120+
```
121+
122+
If the service STILL fails to start, ensure that it is enabled. The following command
123+
will enable the service.
124+
125+
```sh {class="command-line" data-prompt="$"}
126+
sudo launchctl enable system/com.viam.agent
127+
```
128+
109129
- To stop `viam-agent`:
110130

111131
{{< alert title="Alert" color="note" >}}
112132
When you stop `viam-agent`, the agent will stop `viam-server` as well.
113133
{{< /alert >}}
114134

135+
`sudo launchctl kill` and `sudo launchctl stop` will NOT fully stop `viam-agent`, as
136+
launchd will automatically resurrect it. You can use the following to "boot out" the
137+
service and fully stop it.
138+
139+
```sh {class="command-line" data-prompt="$"}
140+
sudo launchctl bootout system/com.viam.agent
141+
```
142+
143+
If you would like to start `viam-agent` again after this command, you will need to
144+
bootstrap it again.
145+
115146
```sh {class="command-line" data-prompt="$"}
116-
sudo launchctl kill SIGTERM system/com.viam.agent
147+
sudo launchctl bootstrap system /Library/LaunchDaemons/com.viam.agent.plist
117148
```
118149

119150
- To completely uninstall `viam-agent` and `viam-server`, run the following command:

docs/operate/reference/viam-server/_index.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -358,17 +358,9 @@ brew tap viamrobotics/brews && brew install viam-server
358358

359359
The `viam-server` binary is installed at <FILE>/opt/homebrew/bin/viam-server</FILE>.
360360

361-
You can optionally run `viam-server` as a background service with Homebrew:
362-
363-
1. Place your machine configuration at <FILE>/opt/homebrew/etc/viam.json</FILE>.
364-
365-
1. Start the service with:
366-
367-
```sh {class="command-line" data-prompt="$" data-output="5-10"}
368-
brew services start viam-server
369-
```
370-
371-
For more information about brew services, run `brew services --help`.
361+
The brew installation of `viam-server` CANNOT be run as a system service in the
362+
background. If you would like to run `viam-server` in the background, install
363+
[`viam-agent`](/manage/reference/viam-agent/) instead.
372364

373365
{{% /tab %}}
374366
{{% tab name="Windows Subsystem for Linux (WSL)" %}}

docs/operate/reference/viam-server/manage-viam-server.md

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -127,29 +127,9 @@ Type **Ctrl + C** on your keyboard within the terminal session where you are run
127127

128128
### Run as a system service
129129

130-
Installing `viam-server` as a system service is not recommended for most use cases on macOS.
131-
However, if you are looking to create a machine that runs on macOS and you want it to run `viam-server` automatically when your macOS system boots, then you will need to run `viam-server` as a service.
132-
133-
Once you have [installed `viam-server`](/operate/install/setup/) on your macOS computer, use the following commands to control the service.
134-
These commands require that you store your machine cloud credentials file at <file>/opt/homebrew/etc/viam.json</file>.
135-
136-
#### Start
137-
138-
```sh {class="command-line" data-prompt="$"}
139-
brew services start viam-server
140-
```
141-
142-
#### Stop
143-
144-
```sh {class="command-line" data-prompt="$"}
145-
brew services stop viam-server
146-
```
147-
148-
#### Restart
149-
150-
```sh {class="command-line" data-prompt="$"}
151-
brew services restart viam-server
152-
```
130+
The brew installation of `viam-server` CANNOT be run as a system service in the
131+
background. If you would like to run `viam-server` in the background, install
132+
[`viam-agent`](/manage/reference/viam-agent/) instead.
153133

154134
{{% /tab %}}
155135
{{< /tabs >}}
@@ -326,12 +306,6 @@ grep viam-server /var/log/syslog
326306

327307
When running `viam-server` on macOS, log messages are written to standard out (`stdout`) in the same terminal session you started `viam-server` in.
328308

329-
You can also access the local `viam-server` log file using the following command:
330-
331-
```sh {class="command-line" data-prompt="$"}
332-
cat $(brew --prefix)/var/log/viam.log
333-
```
334-
335309
{{% /tab %}}
336310
{{< /tabs >}}
337311

0 commit comments

Comments
 (0)