Gadfly/DEPLOY: Difference between revisions
md2wiki: sync from MindAttic.Docs |
md2wiki: sync from MindAttic.Docs |
||
| Line 38: | Line 38: | ||
== Running it locally == | == Running it locally == | ||
<code>run.ps1</code> at the repo root (or a double-click on <code>run.bat</code>) is the MindAttic standard run menu: <code>1</code> Redeploy builds Gadfly.Server, Gadfly.Worker and the CLI (<code>gadfly.exe</code>) into <code>R:\MindAttic\Apps\Gadfly\Debug</code> and <code>\Release</code>, <code>2</code> Run Debug starts the Debug server in this console, <code>3</code> Run Release starts the Release one on its own, and <code>13</code> redeploys then runs Release. Both runs are Development | <code>run.ps1</code> at the repo root (or a double-click on <code>run.bat</code>) is the MindAttic standard run menu: <code>1</code> Redeploy builds Gadfly.Server, Gadfly.Worker and the CLI (<code>gadfly.exe</code>) into <code>R:\MindAttic\Apps\Gadfly\Debug</code> and <code>\Release</code>, <code>2</code> Run Debug starts the Debug server in this console, <code>3</code> Run Release starts the Release one on its own, and <code>13</code> redeploys then runs Release. Both runs are Development against LocalDB (database <code>Gadfly</code>, migrated on start). Run Debug binds <code>localhost</code> only (<code>https://localhost:7311</code>) and passes <code>--Gadfly:AiMode=mock</code>, so no provider is called and nothing is billed. <strong>Run Release is the pilot host (GAD-T831)</strong>: it binds every interface (<code>--urls https://+:7311;http://+:5311</code>), not just <code>localhost</code>, so it is reachable from another machine, and passes <code>--Gadfly:AiMode=live --Gadfly:Voice:Mode=live</code>, a voice id (<code>MindAttic:Avatar:ElevenLabs:VoiceId</code>, until an exam or org picks its own) and a <code>DataProtection:KeysPath</code> outside <code>\Debug</code>/<code>\Release</code> so a redeploy does not invalidate the key ring — every exam taken against it calls the real LLM and ElevenLabs providers and is billed; the keys it needs (<code>MindAttic:Vault:LLM:{elevenlabs,openai,claude,...}:apiKey</code>) come from MindAttic.Vault's <code>LLM</code> bucket on this machine, already loaded by <code>AddMindAtticVaultFiles</code>. Arguments after the switches go to the Debug server, so a seed flag goes last: | ||
<pre class="md-code lang-powershell">.\run.ps1 # the menu | <pre class="md-code lang-powershell">.\run.ps1 # the menu | ||
| Line 47: | Line 47: | ||
The seeders use <code>Gadfly:Demo:Password</code> (for example <code>$env:Gadfly__Demo__Password</code>) as every account's password, or generate one and print it once in the log. The demo tour runs from source: <code>dotnet run --project Gadfly.Tour -- --fresh</code> (docs/TOUR.md). | The seeders use <code>Gadfly:Demo:Password</code> (for example <code>$env:Gadfly__Demo__Password</code>) as every account's password, or generate one and print it once in the log. The demo tour runs from source: <code>dotnet run --project Gadfly.Tour -- --fresh</code> (docs/TOUR.md). | ||
<strong>Reachable from Erin's machine (GAD-T831).</strong> The owner's machine (<code>snowcrash</code>) is <code>100.64.100.7</code> on the same Tailscale network Gadfly's Hetzner host already uses (GAD-T870, <code>https://2-31-204-8.sslip.io</code>); once Erin's device is on that tailnet (Tailscale admin console, or a share invite — a one-time owner step), she reaches the Release host at <code>https://100.64.100.7:7311</code> and accepts the self-signed development certificate warning once. A fresh machine needs one inbound firewall rule first (admin PowerShell, once): | |||
<pre class="md-code lang-powershell">New-NetFirewallRule -DisplayName "Gadfly Pilot Host (7311)" -Direction Inbound -Protocol TCP -LocalPort 7311 -Action Allow -Profile Private</pre> | |||
<strong>Start:</strong> <code>.\run.ps1 -RunRelease</code> (already-built copy) or <code>.\run.ps1 -Redeploy -RunRelease</code> (rebuild first), from <code>D:\Projects\MindAttic\Gadfly</code>, or <code>run.bat</code> picking <code>3</code>/<code>13</code>; it launches <code>Gadfly.Server.exe</code> detached. <strong>Stop:</strong> close its console window, or <code>Stop-Process -Name Gadfly.Server -Force</code> (add <code>-Name Gadfly.Worker</code> too if the worker was started separately). See docs/PILOT.md, "Reaching the local pilot host", for Erin's side of this. | |||
<div class="md2wiki-crumb">Part of [[Gadfly]].</div> | <div class="md2wiki-crumb">Part of [[Gadfly]].</div> | ||
Revision as of 02:07, 30 November 2026
Deploying Gadfly
Status: the Azure deployment was decommissioned on 2026-11-26 (MAT-T297). tools/deploy-azure.ps1, tools/provision-azure.ps1, the azure-deploy.yml workflow and the WebJob files (run.cmd, run.sh, settings.job) were removed in GAD-T804; the resource names, slots, Key Vault and Blob key-ring steps they documented are in git history (commit before GAD-T804). Nothing here creates billable cloud resources.
Production configuration
- Data Protection keys (cookies, launch links, webhook secrets): Production no longer requires a Blob Storage / Key Vault key ring. Set
DataProtection:KeysPath(envDataProtection__KeysPath) to a persistent, private folder so keys survive restarts; without it the library's default key location is used. It must be an absolute path that the web app andGadfly.Workerboth point at, so they share one key ring (startup throws otherwise). - Secrets: every credential comes from MindAttic.Vault (never a literal).
- Database:
ConnectionStrings:Gadfly, a SQL Server database. Development migrates on start; elsewhere run the server once with--migratebefore the new code serves (GAD-T63). - Versions (GAD-T291, GAD-T336): a release build passes
/p:GadflyVersion=N(the next whole number after the highestvNtag) and/p:GadflyCommit=<sha>, and the deploy tags that commitvN; the app showsV<N>and/healthz/versionanswersV<N> <sha>. A local build shows the highest tag plus " dev".
The worker
Exams are taken on the website; grading and the other queued work run in Gadfly.Worker, a console host beside it. It shares the site's service registration (GadflyServices.AddGadflyServices, used by Gadfly.Server/Program.cs and Gadfly.Worker/Program.cs), so it reads the same configuration, connection string and AI panel (Gadfly__AiMode). It stops on SIGTERM / Ctrl+C or when the file named by WEBJOBS_SHUTDOWN_FILE appears, within 50 s; a job cut off mid-run is put back on the queue without using up an attempt.
| Runs in | What |
|---|---|
Worker (and the web app while Gadfly:Jobs:RunInWeb is true)
|
JobWorker (every queued job: AI grading, source processing, email, webhooks, retention, stale-session close, LTI passback and roster refresh, reminders); GradingSweeper, ReminderScheduler, StaleSessionScheduler, RetentionScheduler, LtiPassbackSweeper, LtiRosterRefreshScheduler, ResponseBackfillService
|
| Both, each for its own process | ApiCallTimingWriter and EvidenceSyncWriter, DeskAdminsListWarning
|
| Web app only | Pages, the exam hub and live sessions, voice, the API; the web app always enqueues jobs |
Gadfly:Jobs:RunInWeb (default true): the web app also runs the job worker and sweepers; safe, since a job is claimed by an atomic row update. Set it to false to run the queue only in the worker.
A cold database does not crash startup: the first database call of a start (AuthBootstrapper.SeedAdminAsync) is retried 8 times, 15 s apart, in case a serverless database is still resuming.
Idle shutdown (GAD-T775) (Gadfly.Server/Platform/IdleShutdown.cs) only acts on App Service; elsewhere it stays off.
Locally, .\run.ps1 -Redeploy puts Gadfly.Worker.exe beside the server in R:\MindAttic\Apps\Gadfly\Debug. Run it from there with --environment Development --Gadfly:AiMode=mock, and start the server with .\run.ps1 -RunDebug --Gadfly:Jobs:RunInWeb=false beside it to try the split.
Running it locally
run.ps1 at the repo root (or a double-click on run.bat) is the MindAttic standard run menu: 1 Redeploy builds Gadfly.Server, Gadfly.Worker and the CLI (gadfly.exe) into R:\MindAttic\Apps\Gadfly\Debug and \Release, 2 Run Debug starts the Debug server in this console, 3 Run Release starts the Release one on its own, and 13 redeploys then runs Release. Both runs are Development against LocalDB (database Gadfly, migrated on start). Run Debug binds localhost only (https://localhost:7311) and passes --Gadfly:AiMode=mock, so no provider is called and nothing is billed. Run Release is the pilot host (GAD-T831): it binds every interface (--urls https://+:7311;http://+:5311), not just localhost, so it is reachable from another machine, and passes --Gadfly:AiMode=live --Gadfly:Voice:Mode=live, a voice id (MindAttic:Avatar:ElevenLabs:VoiceId, until an exam or org picks its own) and a DataProtection:KeysPath outside \Debug/\Release so a redeploy does not invalidate the key ring — every exam taken against it calls the real LLM and ElevenLabs providers and is billed; the keys it needs (MindAttic:Vault:LLM:{elevenlabs,openai,claude,...}:apiKey) come from MindAttic.Vault's LLM bucket on this machine, already loaded by AddMindAtticVaultFiles. Arguments after the switches go to the Debug server, so a seed flag goes last:
.\run.ps1 # the menu .\run.ps1 -Redeploy -RunDebug # build, deploy and serve .\run.ps1 -RunDebug --seed-demo # also seed Gadfly Demo Academy (demo.owner ... demo.student) .\run.ps1 -RunDebug --seed-classroom # also seed the classroom (Teacher_A..C, Student_A..Z) .\run.ps1 -Redeploy -DryRun # print what would be built and launched
The seeders use Gadfly:Demo:Password (for example $env:Gadfly__Demo__Password) as every account's password, or generate one and print it once in the log. The demo tour runs from source: dotnet run --project Gadfly.Tour -- --fresh (docs/TOUR.md).
Reachable from Erin's machine (GAD-T831). The owner's machine (snowcrash) is 100.64.100.7 on the same Tailscale network Gadfly's Hetzner host already uses (GAD-T870, https://2-31-204-8.sslip.io); once Erin's device is on that tailnet (Tailscale admin console, or a share invite — a one-time owner step), she reaches the Release host at https://100.64.100.7:7311 and accepts the self-signed development certificate warning once. A fresh machine needs one inbound firewall rule first (admin PowerShell, once):
New-NetFirewallRule -DisplayName "Gadfly Pilot Host (7311)" -Direction Inbound -Protocol TCP -LocalPort 7311 -Action Allow -Profile Private
Start: .\run.ps1 -RunRelease (already-built copy) or .\run.ps1 -Redeploy -RunRelease (rebuild first), from D:\Projects\MindAttic\Gadfly, or run.bat picking 3/13; it launches Gadfly.Server.exe detached. Stop: close its console window, or Stop-Process -Name Gadfly.Server -Force (add -Name Gadfly.Worker too if the worker was started separately). See docs/PILOT.md, "Reaching the local pilot host", for Erin's side of this.