MDK Logo

Run an Avalon worker

Start an MDK worker for a Canaan Avalon device.

Overview

This page details how to run the Canaan Avalon worker. Select the development (mock) or real-device path.

Prerequisites

Review common deployment prerequisites before you start.

Deployment-specific requirements:

  • A Node.js service or script in your deployment that runs the MDK worker and registers devices
  • A supported Avalon device reachable from the machine or container running the worker
  • The miner API reachable over the native CGMiner TCP API, typically port 4028
  • No API username or password. The Avalon CGMiner API is unauthenticated

Development

Run against a mock

To support development, the A1346 ships a runnable example that starts an ORK, boots a mock device, and registers it:

node backend/workers/miners/avalon/examples/run-a1346.js

It prints the ORK HRPC key and the registered device ID, then stays running until Ctrl+C. For the manager class and example file, see USAGE.md.

Connect a miner

Pick your model

Use the Avalon worker's USAGE.md to confirm the manager class and mock example for your model. This guide uses AV_A1346 and run-a1346.js as the example.

Register your miner

Avalon devices use the native CGMiner TCP API on port 4028, which is unauthenticated (no username or password). Add this code to the Node.js service or script that runs the MDK worker in your deployment. The snippet shows the minimum registerThing call for one Avalon device; replace the example IP address with your miner's value:

const { getOrk, startWorker } = require('@tetherto/mdk')
const { AV_A1346 } = require('@tetherto/miner-avalon')

const ork = await getOrk()
const { manager } = await startWorker(AV_A1346, { ork })

await manager.registerThing({
  info: { container: 'site-1', serialNum: 'AV-001' },
  opts: { address: '192.168.1.30', port: 4028 }
})

Make sure each miner's IP is reachable from the machine or container running the worker before registering. Commands act on physical hardware — prioritize thermal safety.

Before running in a deployment, generate the worker config (common.json for worker identity, base.thing.json for device defaults and per-model alert thresholds):

cd backend/workers/miners/avalon
./setup-config.sh

For the full registerThing option reference, the mock createServer options, and the per-model alert blocks, see the worker's USAGE.md and the shared install pattern.

Troubleshooting

The development example on this page uses run-a1346.js. A working run prints ORK HRPC key: and Device:, then stays running until Ctrl+C.

If the example does not print both values, or if its mock port is already in use, follow miner troubleshooting.

Next steps

On this page