Skip to main content
NetScriptdocs Search docs ⌘K v0.0.9
Browse documentation
View as Markdown

Run the ERP sync under Aspire

This chapter runs the whole SAP→Dynamics sync (workers, triggers, queue and cron processors) on one machine under aspire start, and shows you how to read the running system from the dashboard. You wrote none of the orchestration wiring: netscript init scaffolded the AppHost in chapter 1, each plugin you added contributed its own API and background processor to the graph, and one aspire start boots them all with cross-references resolved.

  1. 1 · Scaffold
  2. 2 · Import job
  3. 3 · Polyglot transform
  4. 4 · Queue & cron
  5. 5 · Deploy

What you will build

The full my-erp/ resource graph, up with a single aspire start: Postgres, Redis, the workers API and processor, and the triggers API and processor that runs your file-watch and cron triggers. You initialize the database through the running AppHost and read the import pipeline in the Aspire dashboard: resources, console logs, and the traces that connect a file drop to its job execution.

Before you begin

You need the complete my-erp/ workspace from chapter 4: the workers and triggers plugins, the import-products job, the normalize-sap transform task, the product-import-trigger file watch and the daily-resync-schedule cron. Docker must be running so Aspire can provision Postgres and Redis. Confirm the AppHost was scaffolded (it is a TypeScript/Node program, not C#):

Shell
ls aspire/apphost.mts aspire/aspire.config.json

Both files should exist. netscript init generated them in chapter 1; you never write them by hand.

Step 1 — Understand the graph you are about to run

The resource graph is derived from your installed plugins at boot through composeAppHost. Add a plugin and its API and background processor appear; remove it and they disappear, with no edit to apphost.mts. With workers and triggers installed, aspire start stands up this graph:

What aspire start brings up for the ERP sync
Name · TypeDescription
aspire (dashboard)the URL Aspire prints Live resource list, console logs, structured logs and traces. The generated local profile allows anonymous dashboard access.
OTLP collectorthe OTLP URL Aspire prints OpenTelemetry endpoint the dashboard runs; framework spans and structured logs land here automatically.
postgresContainer Throwaway Docker Postgres. The database netscript db commands target — reachable only while Aspire is up.
redisContainer (cache) Redis cache, the default --cache-backend; Redis-compatible. Backs the KV/queue workloads; auto-discovery resolves the queue to it once it is up.
workers API + processorallocated port + executable The API enqueues; a separate background processor drains the queue and runs your import job.
triggers API + processorallocated port + executable The API plus the processor that runs your file-watch and cron triggers.

As in chapter 1, the plugin APIs have no fixed port: Aspire allocates them at every start, and the dashboard's Resources tab shows the port each resource bound. Pin a plugin with --port only when something outside the graph must keep its address, such as an OAuth callback.

Step 2 — Restore and run

The AppHost runs on its own isolated Node runtime inside aspire/, so its dependencies never leak into your Deno workspace. If aspire start is not still running from earlier chapters, restore once per machine and start it, both from inside aspire/:

Shell
cd aspire
aspire restore   # one-time SDK restore (and after an SDK bump)
aspire start       # boots the whole graph; prints the dashboard URL

aspire start brings up infrastructure first, then the plugin APIs and background processors, with cross-references resolved into injected environment variables. Leave it running.

Step 3 — Initialize the database through the running AppHost

With Aspire up, Postgres is live and the netscript db commands can reach the container Aspire provisioned. Run them from the workspace root in a second terminal, leaving aspire start running in the first:

Shell
netscript db init --name init   # create + apply the first migration
netscript db generate           # generate the Prisma client
netscript db seed               # optional: seed development data

Step 4 — Watch the pipeline run end to end

  1. Drop a file in the SAP export shape:

    Shell
    cat > .data/incoming/products_live.csv <<'CSV'
    material_no,description,price_cents
    ANV-9,Anvil,4999
    CSV
    mv .data/incoming/products_live.csv .data/incoming/products/products_live.csv
    
  2. Open the URL Aspire prints (the generated local profile allows anonymous access).

  3. Read the run in the three dashboard surfaces:

Reading the running ERP sync in the Aspire dashboard
Name · TypeDescription
Resourcestab Every container and executable with status and the port it bound. Confirm workers, triggers, postgres, and redis are all green.
Console logstab stdout/stderr per resource. Open the workers processor to read your import job's log lines; the triggers processor shows the file-watch event.
Structured logs + Tracestab Spans correlated by traceparent. The framework instruments job dispatch and execution automatically, so a file drop → job run trace appears with no extra wiring.

Aspire starts each resource with an OTLP endpoint pointed at the OTLP URL Aspire prints, so framework-level spans (job dispatch, job execution, scheduler runs) appear in the Traces view without extra setup.

Verify your progress

Confirm the whole graph is healthy and the pipeline ran. ns-workers is the workers CLI shorthand you installed in chapter 2.

Shell
# Both plugin APIs answer (endpoints from the Resources tab).
curl <workers-endpoint>/health
curl <triggers-endpoint>/health

# The dropped file produced an import execution.
ns-workers executions --limit=10 --json

Both health checks should return healthy JSON, and the executions feed should show a completed import-products run for products_live.csv.

  • [ ] aspire start is up; the dashboard lists postgres, redis, workers, and triggers all green.
  • [ ] netscript db init/generate succeeded against the Aspire Postgres.
  • [ ] curl <workers-endpoint>/health and curl <triggers-endpoint>/health both return healthy.
  • [ ] A file drop produced an import-products execution and a dispatch/execution trace in the dashboard.

What you built

The complete SAP→Dynamics sync (workers, triggers, queue and cron) running on one machine under a single aspire start, with the database initialized through the running AppHost and a SAP export traced from file drop to durable job execution. You also know where the local setup ends and a production deployment begins.

Next steps

Ship the sync to a remote target with Deploy, the production companion to this local run: deployable units, managed backing services and the --no-aspire path. Related pages:

Search all documentation

Type a term to search the documentation.