# Version Upgrades

# Overview

When deploying an upgrade to the Nekuti Matching Engine, operators should follow the below shutdown procedure to ensure state consistency across the upgrade. This process involves creating a snapshot immediately before shutting down, which guarantees that both the old and new versions of the engine agree on the system state.

# Upgrade Procedure

# Step 1: Snapshot and Shutdown

Before upgrading the engine, call the SnapshotAndShutdown endpoint (Optionally, specify an exit code for the engine process):

curl -X 'PUT' \
  'http://control-gateway:8181/ExchangeWideControls/SnapshotAndShutdown?exitCode=12' \
  -H 'accept: application/json'

# Step 2: Wait for Response

Wait for the endpoint to return its response before proceeding. The engine process will:

  1. Create a complete snapshot of the current state
  2. Return the HTTP response
  3. Exit with the specified exit code (or zero if none provided)

# Step 3: Upgrade and Restart

Once the endpoint has returned and the engine process has exited, it is safe to:

  1. Deploy the new version of the engine
  2. Start the engine immediately

The engine will automatically load the snapshot created in Step 1 and resume operations.

# Snapshotting before non-upgrade restarts

It is safe to perform this upgrade procedure even when the engine version is not being upgraded.

# Best Practices

  1. Schedule upgrades during low-activity periods to minimize the impact of the longer restart time
  2. Monitor the endpoint response to ensure the snapshot completes successfully
  3. Test the upgrade procedure in a staging environment before production deployment