Skip to content

Commit ff70f5b

Browse files
DOCS-3735: Document viam-server environment variable configuration through viam-agent (#4367)
1 parent c710307 commit ff70f5b

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ For information on managing the service, see [Manage `viam-agent`](/manage/refer
103103
"disable_viam_server": false,
104104
"disable_network_configuration": false,
105105
"disable_system_configuration": false
106+
"viam_server_env": {
107+
"CUSTOM_VAR": "value"
108+
}
106109
},
107110
"network_configuration": {
108111
"manufacturer": "viam",
@@ -202,9 +205,42 @@ To update the version of `viam-server` (or the RDK) update the machine settings.
202205
| `disable_network_configuration` | boolean | Optional | Disables the network and hotspot configuration, as well as the configuration of additional networks. Default: `false`. |
203206
| `disable_system_configuration` | boolean | Optional | Disables the system configuration. Default: `false`. |
204207
| `disable_viam_server` | boolean | Optional | Disable `viam-server` remotely. This option is often used by developers working on Viam agent or when manually running `viam-server`. Default: `false`. |
208+
| `viam_server_env` | object | Optional | A map of environment variable names to values that `viam-agent` passes to `viam-server` and its child processes (including modules). Both keys and values must be strings. See [Environment Variables for viam-server](#environment-variables-for-viam-server). Default: `{}` (empty). |
205209
| `viam_server_start_timeout_minutes` | integer | Optional | Specify a time after which, if `viam-server` hasn't successfully started, Viam agent will kill it and restart. Default: `10`. |
206210
| `wait_for_update_check` | boolean | Optional | If set to `true`, `viam-agent` will wait for a network connection and check for updates before starting `viam-server`. See [Reduce startup time](#reduce-startup-time). Default: `false`. |
207211

212+
### Environment Variables for viam-server
213+
214+
You can configure environment variables for `viam-server` using the `viam_server_env` setting in `advanced_settings`.
215+
Environment variables set through `viam_server_env` are passed to `viam-server` and all child processes it launches, including modules.
216+
`viam-server` also inherits existing environment variables from `viam-agent`, such as `HOME`, `PWD`, `TERM`, `PATH`.
217+
218+
{{< alert title="Important" color="note" >}}
219+
When you change environment variables in `viam_server_env`, `viam-agent` will automatically restart `viam-server` to apply these and any other changes made before saving.
220+
This restart will occur immediately if `viam-server` is in a maintenance window and not currently processing configuration changes.
221+
{{< /alert >}}
222+
223+
Changes to `viam_server_env` are the only changes that automatically trigger a `viam-server` restart. Changing other configuration options requires a manual restart unless you've also changed `viam_server_env`.
224+
225+
#### Example configurations
226+
227+
```json
228+
{
229+
"agent": {
230+
"advanced_settings": {
231+
"viam_server_env": {
232+
"PION_LOG_TRACE": "all", # Debug logging for WebRTC
233+
"HTTPS_PROXY": "socks5://proxy.example.com:1080", # SOCKS proxy
234+
"HTTP_PROXY": "socks5://proxy.example.com:1080",
235+
"CUSTOM_VAR": "value"
236+
}
237+
}
238+
}
239+
}
240+
```
241+
242+
To remove an environment variable, remove it from the `viam_server_env` object and save your configuration.
243+
208244
### Reduce startup time
209245

210246
You can set `wait_for_update_check` to `false` to bypass `viam-agent` waiting for a network connection to be established and checking for updates during initial startup.

0 commit comments

Comments
 (0)