Each site runs its own air. One per folder. Each air watches only its own folder if you add .air.toml.
The rule
text
~/CMS/ai/ → runs its own air on port 8080
~/CMS/officialstupid-me → runs its own air on port 8081
~/CMS/anything-else → runs its own air on port 8082
One terminal per site. Each cd into its folder, each runs air.
Step 1 — Add .air.toml to every site
In each site folder:
bash
cd ~/CMS/ai
cat > .air.toml <<'EOF'
root = "."
tmp_dir = "tmp"
[build]
cmd = "go build -o ./tmp/cms main.go"
bin = "./tmp/cms"
include_ext = ["go", "html", "css", "js"]
exclude_dir = ["tmp", "uploads", "node_modules", ".git"]
delay = 200
stop_on_error = true
send_interrupt = false
kill_delay = "500ms"
[log]
time = true
main_only = true
EOF
Do the same for officialstupid-me.
Step 2 — Change the port per site
Currently both sites default to 127.0.0.1:8080. They will conflict.
Edit main.go in each site. Find:
go
Addr: "127.0.0.1:8080",
Change to use an env variable:
go
addr := os.Getenv("CMS_ADDR")
if addr == "" {
addr = "127.0.0.1:8080"
}
And in the srv := &http.Server{...} block:
go
Addr: addr,
Do that once per site. Then start each with a different port.
Step 3 — Run each site on its own port
Terminal 1:
bash
cd ~/CMS/ai CMS_ADDR=127.0.0.1:8080 air
Terminal 2:
bash
cd ~/CMS/officialstupid-me CMS_ADDR=127.0.0.1:8081 air
Browser:
http://127.0.0.1:8080/→aisitehttp://127.0.0.1:8081/→officialstupid-me
Both run at the same time. Completely isolated.
Step 4 — Clean up stray build artifacts
Your tree shows tmp/cms and tmp/main in both sites. Those are from air. tmp/ is safe to delete anytime — air will recreate it.
bash
rm -rf ~/CMS/ai/tmp ~/CMS/officialstupid-me/tmp
Also ~/CMS/ai/data.db-shm and data.db-wal are runtime files that travel with data.db. Keep them.
Step 5 — What to keep vs delete per site
Keep (per site):
main.go,go.mod,go.sumtemplates/,static/,uploads/data.db,data.db-shm,data.db-wal.password_hash(if it exists).air.toml
Delete or ignore:
tmp/(build cache — auto-created)cmsbinary in the root (leftover)main.7zandmain-good.7z— your personal backups, up to you
Step 6 — Template for future sites
Make one clean template folder to clone from.
bash
cd ~/CMS mkdir -p _template cp ai/main.go _template/ cp ai/go.mod _template/ cp ai/go.sum _template/ cp -r ai/templates _template/ cp -r ai/static _template/ cp ai/.air.toml _template/
To start a new site:
bash
cd ~/CMS cp -r _template new-site cd new-site mkdir -p uploads # edit main.go: change defaultPassword, add CMS_ADDR env, change site title in base.html CMS_ADDR=127.0.0.1:8082 air