Previous
Module configuration
Modules run on your machine, alongside viam-server
as separate processes, communicating with viam-server
over UNIX sockets.
viam-server
manages the dependencies, start-up, reconfiguration, data management, and shutdown behavior of your modular resource.
The lifecycle of a module and the resources it provides is as follows:
viam-server
starts, and if it is connected to the internet, it checks for configuration updates.
viam-server
starts any configured modules.
When a module initializes, it registers its model or models and associated APIs with viam-server
, making the models available for use.
For each modular resource configured on the machine, viam-server
uses the resource’s validate
function and the depends_on
field in the resource configuration to determine the dependencies of the resource.
If a required dependency is not already running, viam-server
starts it before starting the resource.
If a required dependency is not found or fails to start, viam-server
will not start the resource that depends on it.
viam-server
calls the resource’s constructor to build the resource based on its configuration.
Typically, the constructor calls the reconfigure function.
If construction or reconfiguration fails due to a validation failure or an exception thrown by the modular resource’s constructor or its reconfigure method, viam-server
attempts to construct or reconfigure the resource every 5 seconds.
If the module exceeds the configured timeout limits (default 5 minutes to start up and 1 minute to reconfigure), viam-server
logs an error.
Once the modular resource has started up and configured, it is available for use.
If at any point the user changes the configuration of the machine, viam-server
reconfigures the affected resources within 15 seconds.
If viam-server
attempts to shut down an individual module (for example due to a user disabling a module) and the module does not shut down within 30 seconds, viam-server
kills the module.
When viam-server
shuts down, it first attempts to shut down each module sequentially in no particular order.
If a given module does not shut down within 30 seconds, it is killed with a SIGKILL
.
If any modules are still running after 90 seconds, viam-server
kills them as well.
This means that if four modules are running and the first three each fail to shut down within 30 seconds each, the fourth is killed immediately at the 90 second mark.
Microcontroller modules function differently and are embedded in the firmware you flash onto your device. For more information see Modules for ESP32.
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!