Manage viam-server

If you have manually installed viam-server, you can chose to run it as a system service or directly on the command line. Running as a system service enables you to configure viam-server to start automatically when your system boots, and is the default installation option on Linux. Running on the command line is suitable for local development.

Run viam-server

Select the tab for your platform:

Run as a system service

After installation, the viam-server AppImage binary will be located at /usr/local/bin/viam-server, and a systemd service file will be placed at /etc/systemd/system/viam-server.service. By default, viam-server is configured to start when the machine boots.

Running viam-server as a system service is the recommended method for Linux.

You can use the following commands to manage viam-server when installed as a system service. These commands require that you store your configuration file at /etc/viam.json.

Start

sudo systemctl start viam-server

Stop

sudo systemctl stop viam-server

Restart

sudo systemctl restart viam-server

Enable (start automatically with system boot, default)

sudo systemctl enable viam-server

Disable (do not start automatically with system boot)

sudo systemctl disable viam-server

Run from the command line

When running viam-server on the command line, you can use the following commands to manage the process. If viam-server is already running as a system service, be sure to stop the service first before using these commands.

Start

Run the following on the command line to start viam-server, providing the path to your configuration file:

sudo viam-server -config /path/to/my/config.json

If you followed the Installation Guide, your machine’s configuration file is available at /etc/viam.json. You can provide this path in the above command, or move the configuration file to a desired location and change the path in this command accordingly.

Note that on a Raspberry Pi, viam-server must always run as root (using sudo) in order to access the DMA subsystem for GPIO. When running viam-server from your home directory on a Linux computer, you do not need to use sudo.

Stop

Press Ctrl + C on your keyboard within the terminal session where you are running viam-server to stop it.

Run from the command line

After installation, viam-server can be run directly on the command line.

Running viam-server on the command line is the recommended method for macOS.

You can use the following commands to manage viam-server on the command line:

Start

Run the following on the command line to start viam-server, providing the path to your own configuration file:

viam-server -config /path/to/my/config.json

If you followed the Installation Guide, your machine’s configuration file is available in your ~/Downloads/ directory, named similarly to viam-machinename-main.json. You can provide this path in the above command, or move the configuration file to a desired location and change the path in this command accordingly.

Stop

Type Ctrl + C on your keyboard within the terminal session where you are running viam-server to stop it.


Run as a system service

Installing viam-server as a system service is not recommended for most use cases on macOS. 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.

Once you have installed viam-server on your macOS computer, use the following commands to control the service. These commands require that you store your configuration file at /opt/homebrew/etc/viam.json.

Start

brew services start viam-server

Stop

brew services stop viam-server

Restart

brew services restart viam-server

Update viam-server

The steps to update viam-server differ depending on your installation method. To determine your installation method, check if the viam-agent process is running. Run the following command:

ps aux | grep viam-agent
root      566431  0.5  0.2 1247148 20336 ?       Ssl  11:24   0:00 /opt/viam/bin/viam-agent --config /etc/viam.json

If the output includes a process named viam-agent, you used viam-agent to install viam-server. Follow the steps to use viam-agent to update viam-server.

If the output does not include a process named viam-agent, you did not use viam-agent. Follow the manual steps to update the standalone version.

By default, viam-agent automatically upgrades to the latest stable version of viam-server. You can change this behavior in the version_control settings of your machine in the Viam app. For example, the following version_control configuration will always update to the latest stable release of viam-agent and the latest development release of viam-server:

{
  "agent": {
    "version_control": {
      "agent": "stable",
      "viam-server": "dev"
    }
  },
  "components": [ ... ]
}

To use the new versions of viam-server and viam-agent, restart viam-agent. When you stop or restart viam-agent, the agent also restarts viam-server.

To update to the newest RDK version, you need to update your viam-server. Select the tab for your platform:

viam-server is distributed for Linux as an AppImage, and includes a built-in self-update feature. When you run viam-server as a service on Linux, it will check for updates automatically on launch, and update itself if a newer version is detected.

The automatic update behavior of viam-server should meet the needs of most deployments, but if you need to manually force an update, you can do so with the --aix-update flag:

sudo viam-server --aix-update

viam-server is distributed for macOS through the Homebrew package manager, which includes a built-in update feature.

To upgrade to the latest version of viam-server using Homebrew:

brew upgrade viam-server

Homebrew does not support automatic updates, so you will need to manually perform this step each time you wish to check for updates. We recommend running brew upgrade viam-server on a regular basis.

Disable automatic updates

To disable automatic updates, configure the version_control settings of your machine in the Viam app to a specific version number. For example, the following version_control configuration pins viam-server to version 0.52.1, preventing viam-server from updating to a more recent version:

{
  "agent": {
    "version_control": {
      "agent": "stable",
      "viam-server": "0.52.1"
    }
  },
  "components": [ ... ]
}

If you are changing to a different version of viam-server and viam-agent, restart viam-agent. When you stop or restart viam-agent, the agent also restarts viam-server.

viam-server automatically checks for updates. On Linux, you can disable automatic viam-server updates. To disable the updates, open /etc/systemd/system/viam-server.service and comment out the line that starts with ExecStartPre. Add a # character at the beginning of the line so that it matches the following:

# ExecStartPre=-/usr/local/bin/viam-server --aix-update

Then, reload the service file with the following command:

sudo systemctl daemon-reload

To resume automatic update checking, delete the leading # character in /etc/systemd/system/viam-server.service, then run sudo systemctl daemon-reload again.

View viam-server logs

viam-server writes log messages as it starts up and runs, providing useful information when managing or troubleshooting the process. Use the following commands to view these log messages locally on your system.

Select the tab below for your platform:

As a system service

If you are running viam-server as a system service, run the following command to view log messages:

sudo journalctl --unit=viam-server

Use the arrow keys to page vertically or horizontally through the log messages.

You can also “tail” the logs, viewing new messages as they come in with:

sudo journalctl -f --unit=viam-server

Use the q key to stop following the logs.

You can also view log messages specific to viam-server in the syslog with the following command:

grep viam-server /var/log/syslog

From the command line

If you are running viam-server on the command line, log messages are written to standard out (stdout) in the same terminal session you started viam-server in.

You can also view log messages specific to viam-server in the syslog with the following command:

grep viam-server /var/log/syslog

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

You can also access the local viam-server log file using the following command:

cat $(brew --prefix)/var/log/viam.log

Uninstall viam-server

Remove the system installed service with the following three commands:

sudo systemctl disable --now viam-server
sudo rm /etc/systemd/system/viam-server.service
sudo systemctl daemon-reload

To remove the configuration file, run:

sudo rm /etc/viam.json

To remove various Viam caches and logs for the root (service) user, run:

sudo rm -r /root/.viam/

If you ever run viam-server directly, to remove various Viam caches and logs for your own user run:

rm -r ~/.viam/

To remove the viam-server binary itself, run:

sudo rm /usr/local/bin/viam-server

Uninstall viam-server with the following command:

brew uninstall viam-server

To remove various Viam caches and logs, run:

rm -r ~/.viam/

To remove the configuration file, run:

sudo rm /etc/viam.json

Troubleshooting

You can find additional assistance in the Troubleshooting section.