Skip to content

Publish a new version

Applies to version 0.110 min

At the end of this page you will have replaced the bundle that a running gateway serves with a new version, without a restart, and seen in the log when the gateway switched and which version served each request. It uses the mock, so you need no IBM i.

Before you start, you need what Serve with a mock needs, in an empty folder with the apis/ files of the quickstart.

This installs slay400, the generator, and the gateway, as Serve with a mock explains:

curl -fsSL https://raw.githubusercontent.com/generativearchitects-ai/slay400-core/main/install.sh | sh
export PATH="$HOME/.slay400/bin:$PATH"
curl -fsSL https://raw.githubusercontent.com/generativearchitects-ai/slay400/main/install.sh | sh
export PATH="$HOME/.slay400-gateway/bin:$PATH"

Each prints where it installed the tool and the line that puts it on your PATH.

Build the same APIs twice, as version 1.0.0 and 1.1.0 of the bundle shop:

slay400 init
slay400 bundle --name shop --version 1.0.0 --out build/shop-1.0.0.rpgapi
slay400 bundle --name shop --version 1.1.0 --out build/shop-1.1.0.rpgapi

The gateway serves every *.rpgapi file of a folder named in bundles. This copies version 1.0.0 into bundles/ and writes a configuration that looks at the folder every second (reload.intervalSeconds; the default is 10):

mkdir -p bundles
cp build/shop-1.0.0.rpgapi bundles/shop.rpgapi
cat > config.yaml <<'YAML'
reload:
  intervalSeconds: 1
tenants:
  acme:
    bundles: [./bundles]
    environments:
      test: { code: T0001, backend: mock }
YAML

Start the gateway:

slay400-gateway run --config config.yaml > gateway.log 2>&1 &
until curl -fs -o /dev/null http://127.0.0.1:8080/health/ready; do sleep 1; done

Call an operation, and look at which version served it:

curl -s http://127.0.0.1:8080/acme/test/orders/1001/status
grep -o '"bundle":"shop","bundleVersion":"[^"]*"' gateway.log

It prints the answer, then the bundle and version of the access line:

{"status":"S","deliveryDate":"2026-11-20"}"bundle":"shop","bundleVersion":"1.0.0"

Copy the new file next to the old one under another name, then rename it into place: the rename is a single step, so the gateway never sees half a file. It loads a changed folder only once it has stayed the same for two looks in a row. The last command waits for the line that the gateway writes when it switches:

cp build/shop-1.1.0.rpgapi bundles/shop.rpgapi.part
mv bundles/shop.rpgapi.part bundles/shop.rpgapi
until grep -q '"event":"reloaded"' gateway.log; do sleep 1; done
grep -o '"event":"reloaded","bundles":\[[^]]*\],"operations":{[^}]*}' gateway.log

It prints the switch: the bundles now served, and the operations added, removed and changed:

"event":"reloaded","bundles":[{"tenant":"acme","name":"shop","version":"1.1.0"}],"operations":{"added":0,"removed":0,"changed":0}

The line also has durationMs, how long the load took. Requests that arrived before the switch finish on version 1.0.0; none fails or waits.

Call again:

curl -s http://127.0.0.1:8080/acme/test/orders/1001/status
grep -o '"bundle":"shop","bundleVersion":"[^"]*"' gateway.log | tail -n 1

The answer is the same, and version 1.1.0 served it:

{"status":"S","deliveryDate":"2026-11-20"}"bundle":"shop","bundleVersion":"1.1.0"

If the new set cannot be loaded, the gateway keeps the old one and writes one warning with the diagnostics; it tries again only when the files change again.

kill $!

To clean up, delete the folder.