Configure a Process to Run on Your Machine
To automatically run a specified command when your machine boots, configure a process.
A process can be any command, for example one that executes a binary or a script.
You can configure a process to run once when the machine first starts, or to run continuously alongside viam-server
.
Set up dependencies for control code to run as a process
If you are configuring a process to run a script that does not use Viam SDKs, skip this section and continue to Configure a process. Due to the way processes are designed for stability, if you are configuring a process to run a Viam SDK script, you need to install the relevant SDK as well as other required dependencies in a specific way on your SBC:
ssh
into your board and installpip
:sudo apt install -y python3-pip
Install the Viam Python SDK (and other dependencies if required) into a new folder called
robot
:pip3 install --target=robot viam-sdk <other-required-dependencies>
Display the full path of the current directory you are working in on your board. Make a note of this output for the next step.
pwd
Add your code to the
robot folder.
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.
Your process is automatically created with a name (id
in JSON) like process-1 and a card matching that name on the CONFIGURE tab.
Navigate to that card.
Then fill in the following fields:
Attribute (Builder Mode) | Attribute (JSON) | 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 with 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. |
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.
|
Click Save in the upper right corner of the screen to save your config.
Example
The following example configuration executes the command python3 my_cool_script.py
in your
The corresponding JSON looks like this:
"processes": [
{
"id": "run-my-code",
"log": true,
"name": "python3",
"args": [
"my_cool_script.py"
],
"cwd": "/home/myName/project/"
}
]
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!