Supervisor

Supervisor

This tool runs on the robot and is responsible for managing releases. This includes both executing software processes, monitoring them, and handling deploys (for both software and ArkOS).

The Supervisor is controlled through the standard Ark message commands. It exposes a web server on port 8081. You can communicate with it through the messages defined in ark/supervisor/messages.rbuf, or use the ark-supervisor-tool to control it from the command line.

Command Line Tools

You can query the Platform Supervisor of its current status like so:

./build/ark-supervisor-tool --query
Supervisor Status:
{
  "processes": [
    {
      "last_return_code": 0,
      "last_terminating_signal": 0,
      "name": "Nano Data Collection Pipeline",
      "output_contents": "<...>",
      "start_count": 1,
      "state": "Running"
    }
  ]
}

There are also options for starting/stopping processes. You can use the --start-all or --stop-all command line arguments to start/stop the process.

Finally, you can watch standard output using --watch:

./build/ark-supervisor-tool --watch -o "Data Collection"
(2021-06-07 13:00:26.320) [info] (websocket_client.cc:417) Established connection to 127.0.0.1:8081 and subscribed to '/status'.
(2021-06-07 12:59:29.620) [warn] (video_device.cc:945) Requested control 'gain' not supported by device.
(2021-06-07 12:59:29.620) [warn] (video_device.cc:945) Requested control 'override_enable' not supported by device.
(2021-06-07 12:59:29.620) [warn] (video_device.cc:945) Requested control 'sensor_mode' not supported by device.

Because you can interact with the Supervisor through normal Ark communications, its possible for you to control software updates, monitor the console, or restart software from within your web or Qt applications.

Custom Command Line Options

You can start processes on the Supervisor with customized command line options, which can make testing/iterating faster.

For example:

./build/ark-supervisor-tool --host localhost:8081 --start-all --start-with-arguments 'Data Collection Pipeline' -- --initial-log-name 'Testing'

Assuming the processes were stopped, running that will start the data collection pipeline with custom command line arguments that start logging on startup. You can pass in any command line arguments you want to the processes.

You can also modify the config package (or any of its child files) directly, and simply start that process with your local config package:

./build/ark-supervisor-tool --host localhost:8081 --start-all --start-with-arguments 'Data Collection Pipeline' --start-with-config-package ./ark/data_collection/data_collection_nuc.yml

That command starts the data collection pipeline with the config package on your local machine. One caveat is that if the process crashes, or you restart it, it will restart with the original command line arguments.

Since this can be used to run with customized configurations or command lines, it is recommended that you only use this for testing.

Production Lock

The production lock allows you to ’lock out’ commands to deploy new software or start/stop the software. This is useful for when your robot is in ‘production’ and you want to prevent accidental deploys.

The production lock can be temporarily disabled to allow deploys. To enable it:

./build/ark-supervisor-tool --host localhost:8081 --enable-production-lock

To disable it for some time period (for example, 5 minutes):

./build/ark-supervisor-tool --host localhost:8081 --disable-production-lock 300

Once the timeout expires, the lock will be re-enabled.

You’ll likely want to enable the production lock on startup – this can be acheived by passing the --production-lock command line argument to ark-platform-supervisor when it is starting. If passed, commands to start/stop/deploy software will all be disabled until someone disables the production lock.

Enabling/disabling the production lock is acheived by simply sending messages to the supervisor. You can do this from your pipeline if desired, for example, to disable deploys/starting/stopping software while a robot is active.

To do so, send a ark::supervisor::ProductionLockRequest message to the pipeline. You can typically do this via the REST interface:

ark::core::Url host_url("localhost:8081/software/lock/publisher");
// Enable lock
ark::comms::http_put(i
    host_url,
    ark::serialization::serialize(
        ark::supervisor::ProductionLockRequest{.enabled = true, .requestor = "name-for-debugging"}));

// Disable lock
ark::comms::http_put(
    host_url,
    ark::serialization::serialize(
        ark::supervisor::ProductionLockRequest{.enabled = false,
                                               .lock_disable_duration_s = 300.0,
                                               .requestor = "name-for-debugging"});