Configure a managed process
To run a program or control code when your machine is online, configure a process.
The process is managed by viam-server
.
You can configure processes to run once upon startup or indefinitely.
In this page
Configure a process
Navigate to the CONFIGURE tab of your machine’s page in the Viam app. Click the + icon next to your machine part in the left-hand menu and select Process.
In the process configuration panel, configure the attributes for your process:
Attribute | Type | Required? | Description |
---|---|---|---|
Executable (name ) | string | Required | The command you want to execute when your machine connects to the server. On many operating systems, you can find the executable path of commands by running which <command-name> . |
Arguments (args ) | string[] | Optional | Arguments to follow the command. |
Working directory (cwd ) | string | Optional | Where you want the process to execute. Defaults to the directory where viam-server executes. |
username (not available in builder mode) | string | Optional | Run this process as a different user. Example: "username": "ubuntu" . |
env (not available in builder mode) | Map<string, string> | Optional | Environment variables for the process. Environment variables are encrypted in transit but are stored in plain text in the configuration file that resides on the machine. Example: "environment": { "SVC_API_KEY":"VALUE" } . |
Logging (log ) | boolean | Optional | Toggle logging of errors and other messages on or off. Default: false . |
Execute once (one_shot ) | boolean | Optional | Toggle whether to execute the command just once or keep running the process indefinitely.
false . |
Click Save in the upper right corner of the screen.
Example
The following example executes the command python3 my_cool_script.py
in your
"processes": [
{
"id": "run-my-code",
"log": true,
"name": "python3",
"args": [
"my_cool_script.py"
],
"cwd": "/home/myName/project/"
}
]
Set up dependencies
If you are configuring a process that requires dependencies, such as the Viam SDKs, you must install those dependencies so viam-server
has access to them.
For Python scripts, we recommend you install dependencies into the folder that contains the code you want to execute:
sudo apt install -y python3-pip
pip3 install --target=machine viam-sdk <other-required-dependencies>
Have questions, or want to meet other people working on robots? Join our Community Discord.
If you notice any issues with the documentation, feel free to file an issue or edit this file.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!