Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/docs/src/content/docs/contribute/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ pnpm dev

This starts the example app on `http://localhost:3000` by default. It also rebuilds and watches the workspace packages that the example app consumes, so dashboard and runtime package edits are reflected without manually rebuilding first.

`pnpm dev` delivers background work through BullMQ on the Redis in `compose.yaml` (`redis://localhost:6382`). Start it with `docker compose up -d redis`. Local work then needs no Vercel Queues access. To use Vercel Queues, set `JUNIOR_QUEUE_PROVIDER=vercel` and run `pnpm dev:env` for the Vercel token. To use another Redis, set `JUNIOR_QUEUE_REDIS_URL`.
Before the app starts, `pnpm dev` runs `docker compose up -d --wait`. This starts Postgres, Redis and S3 from `compose.yaml` and waits until they are healthy. Docker must be running. Services that already run are left as they are. Then `pnpm dev` runs `junior upgrade` to apply missing database migrations to `DATABASE_URL`. Migrations that already ran are skipped. If either step fails, `pnpm dev` stops.

`pnpm dev` delivers background work through BullMQ on the Redis in `compose.yaml` (`redis://localhost:6382`), which `pnpm dev` starts. Local work then needs no Vercel Queues access. To use Vercel Queues, set `JUNIOR_QUEUE_PROVIDER=vercel` and run `pnpm dev:env` for the Vercel token. To use another Redis, set `JUNIOR_QUEUE_REDIS_URL`.

With BullMQ, `pnpm dev` starts one queue worker process next to Nitro. Nitro accepts requests and sends jobs. The worker runs them. A new Junior build restarts both processes. A change to `apps/example/server.ts`, `plugins.ts`, `dashboard.ts` or `apps/example/app/` restarts only the worker. The worker and Nitro must share state, so `pnpm dev` keeps state in that Redis unless you set `JUNIOR_STATE_ADAPTER`. `JUNIOR_STATE_ADAPTER=memory` does not work with BullMQ. Each queue topic runs up to 4 jobs at the same time. Set `JUNIOR_QUEUE_WORKER_CONCURRENCY` to change that number.

Expand Down
15 changes: 15 additions & 0 deletions scripts/dev-server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ function runRequiredChild(command, args, options = {}) {
...options,
});

if (result.error) {
console.error(`Failed to run ${command}: ${result.error.message}`);
process.exit(1);
}
if (result.signal) {
process.kill(process.pid, result.signal);
return;
Expand Down Expand Up @@ -411,6 +415,11 @@ function watchForRestarts() {
});
}

// Start Postgres, Redis and S3 from `compose.yaml`, and wait until they are
// healthy. Services that already run are left as they are.
runRequiredChild("docker", ["compose", "up", "-d", "--wait"], {
cwd: workspaceRoot,
});
Comment thread
sentry-junior[bot] marked this conversation as resolved.
Resolved
runRequiredChild("pnpm", ["build"], {
cwd: juniorPackageDir,
});
Expand All @@ -422,6 +431,12 @@ syncInjectedPackageDist("@sentry/junior-dashboard", dashboardPackageDir, {
strict: true,
});
clearExampleVercelOutput();
// Apply missing core and plugin migrations before Nitro and the worker start.
// `junior upgrade` skips migrations that already ran, so this is safe on
// every start.
runRequiredChild("pnpm", ["exec", "junior", "upgrade"], {
cwd: exampleDir,
});

spawnChild(
"pnpm",
Expand Down
Loading