mirror of
https://github.com/kellymichels/zscripts-token-savers
synced 2026-10-07 07:18:18 +00:00
* feat(zstart): support uvicorn/ASGI apps via a startApp config field Python projects could only be started as `python -m <startModule>`, so FastAPI/ASGI apps that run under uvicorn (like evo-ai: `uvicorn app.main:app`) couldn't be started by zstart in either port. Add an optional `startApp` field. When set, zstart runs `uvicorn <startApp> --host <bind-host> --port <ports.dev> --reload` via the venv python's -m (no PATH juggling), integrating zstart's existing bind-host and dev-port handling. startApp takes precedence over startModule; a python project still needs one or the other. Applied to bash and PowerShell, documented in the README + example configs. * feat(zstart): warn when falling back to system python (no project venv) A python project with no .venv (or only a Windows .venv when on WSL) silently ran under the system interpreter, which usually lacks the project's deps - producing a cryptic ModuleNotFoundError far from the cause. Now zstart prints a clear warning naming the missing venv and the one-liner to create it, before starting. Bash + PowerShell. * fix(bash): zstart --detached no longer hangs on the tracking FIFO Detached mode forked the long-lived server while it still inherited the ztokens tracking fds (the capture FIFO on 1/2, saved stdout/stderr on 3/4). The parent's EXIT-trap footer runs `tee` on that FIFO and waits for EOF, which never came while the server held it open - so `zstart --detached` (and zstartd / zrestart --detached) hung instead of returning. detach() now redirects stdin<-/dev/null, stdout/stderr->log and closes fd 3/4 before exec'ing the server. Verified on WSL: detached returns in 0s and the server still boots. * fix(zstart): git-pull pre-step can't hang on a credential prompt start.gitPull ran `git pull --ff-only` before starting the server; in an environment with no cached git credentials (e.g. WSL against an HTTPS GitHub remote) git prompted "Username for 'https://github.com':" and the whole start blocked on stdin. Run the pull with GIT_TERMINAL_PROMPT=0 so it fails fast, log a clear "auto-pull skipped" note, and start with the current checkout. Bash + PowerShell.
87 lines
3.1 KiB
JSON
87 lines
3.1 KiB
JSON
{
|
|
"_comment": "Copy this file to zconfig.json and fill in your values. zconfig.json is gitignored — never commit it.",
|
|
|
|
"ec2": {
|
|
"ip": "YOUR_SERVER_IP",
|
|
"user": "YOUR_SSH_USER",
|
|
"pemKey": "/home/youruser/.ssh/YourKey.pem",
|
|
"stackRoot": "/home/YOUR_SSH_USER/stack"
|
|
},
|
|
|
|
"paths": {
|
|
"temp": "/tmp/zscripts",
|
|
"backupsLocal": "/home/youruser/backups/projects",
|
|
"backupsEc2": "/home/youruser/backups/ec2",
|
|
"scriptsRoot": "/home/youruser/zscripts/bash",
|
|
"oneDriveBackups": ""
|
|
},
|
|
|
|
"ztokens": {
|
|
"_comment": "Optional. Where each run's token-usage stats (tokens.jsonl) are recorded. Omit to use ~/.ztokens/data.",
|
|
"dataDir": "/home/youruser/.ztokens/data"
|
|
},
|
|
|
|
"projects": {
|
|
"_comment": "Rename these keys to your own project names — the key IS the command argument: zstart pyapp, zdeploy viteapp, zbackup nextapp. Add as many projects as you like. Keys starting with _ are ignored.",
|
|
|
|
"pyapp": {
|
|
"label": "My Python App",
|
|
"kind": "python",
|
|
"localRoot": "/home/youruser/code/pyapp",
|
|
"startModule": "pyapp.main",
|
|
"_startApp_note": "ASGI/FastAPI app? Use \"startApp\": \"app.main:app\" instead of startModule (runs uvicorn --port <dev> --reload).",
|
|
"ports": { "dev": 8080 },
|
|
"domain": "pyapp.yourdomain.com",
|
|
"start": {
|
|
"_comment": "Optional zstart pre-steps: gitPull runs 'git pull --ff-only' first; env sets variables for the server process.",
|
|
"gitPull": true,
|
|
"env": { "MYAPP_DEBUG": "1" }
|
|
},
|
|
"db": { "user": "pyapp_user", "name": "pyapp_db" },
|
|
"remote": {
|
|
"path": "/home/YOUR_SSH_USER/stack/pyapp",
|
|
"composeDir": "/home/YOUR_SSH_USER/stack/pyapp/docker",
|
|
"appService": "app"
|
|
},
|
|
"deploy": { "zipName": "PyAppDeploy.zip", "gitPull": true, "exclude": ["docs"] }
|
|
},
|
|
|
|
"viteapp": {
|
|
"label": "My Vite Site",
|
|
"kind": "vite",
|
|
"localRoot": "/home/youruser/code/viteapp",
|
|
"ports": { "dev": 5173 },
|
|
"domain": "www.yourdomain.com",
|
|
"remote": {
|
|
"path": "/home/YOUR_SSH_USER/stack/viteapp",
|
|
"containerName": "viteapp"
|
|
},
|
|
"deploy": { "zipName": "ViteAppDeploy.zip" }
|
|
},
|
|
|
|
"nextapp": {
|
|
"label": "My Next.js App",
|
|
"kind": "nextjs",
|
|
"localRoot": "/home/youruser/code/nextapp",
|
|
"ports": { "dev": 4173, "prod": 3000 },
|
|
"domain": "app.yourdomain.com",
|
|
"migrations": "prisma",
|
|
"db": { "user": "nextapp_user", "name": "nextapp_db" },
|
|
"remote": {
|
|
"path": "/home/YOUR_SSH_USER/stack/nextapp",
|
|
"appService": "web"
|
|
},
|
|
"deploy": { "zipName": "NextAppDeploy.zip" }
|
|
},
|
|
|
|
"edge": {
|
|
"label": "Edge Proxy",
|
|
"kind": "edge",
|
|
"localRoot": "/home/youruser/code/edge",
|
|
"proxyContainer": "edge-proxy",
|
|
"certsSource": "/etc/letsencrypt",
|
|
"remote": { "path": "/home/YOUR_SSH_USER/stack/edge" }
|
|
}
|
|
}
|
|
}
|