Feat/subdomain port binding - #12
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (14)
🔥 Files not summarized due to errors (1)
📝 WalkthroughWalkthroughThe PR removes the ChangesDeployment package removal
Port allocation flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant deployRoute
participant findAvailablePort
participant database
participant goportscan
deployRoute->>findAvailablePort: Request available port
findAvailablePort->>database: Query deployed and deploying ports
database-->>findAvailablePort: Return occupied ports
findAvailablePort->>goportscan: Write occupied ports to stdin
goportscan-->>findAvailablePort: Return selected port
findAvailablePort-->>deployRoute: Resolve selected port
deployRoute->>deployRoute: Log selected container port
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR updates the server’s port-allocation flow for Docker deployments by making goportscan execution asynchronous and (intended) aware of ports already tracked in the SQLite deployments table, and it removes a previously committed deployment/CLI sandbox under server/deployments/a2a1ac.
Changes:
- Refactors
findAvailablePort()to useexecFile(async) and adds a DB-backed “used ports” query. - Adds an extra deploy-time log line after selecting the Docker host port.
- Deletes the
server/deployments/a2a1acsandbox directory contents.
Reviewed changes
Copilot reviewed 13 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| server/src/utils/goPortFinder.ts | Switches to async execFile and attempts to stream used ports into goportscan. |
| server/src/routes/deploy.ts | Adds logging for the selected Docker host port (minor formatting issue). |
| server/src/config/db.ts | Introduces getUsedPorts() to query ports from deployments. |
| server/deployments/a2a1ac/tsconfig.json | Removed sandbox TS config. |
| server/deployments/a2a1ac/src/utils/logger.ts | Removed sandbox logger utility. |
| server/deployments/a2a1ac/src/utils/configHelper.ts | Removed sandbox config helper. |
| server/deployments/a2a1ac/src/utils/archieve.ts | Removed sandbox archive utility. |
| server/deployments/a2a1ac/src/index.ts | Removed sandbox CLI entrypoint. |
| server/deployments/a2a1ac/package.json | Removed sandbox package manifest. |
| server/deployments/a2a1ac/package-lock.json | Removed sandbox lockfile. |
| server/deployments/a2a1ac/index.html | Removed sandbox HTML page. |
| server/deployments/a2a1ac/Dockerfile | Removed sandbox Dockerfile. |
| server/deployments/a2a1ac/aerocloud.json | Removed sandbox example config. |
| server/deployments/a2a1ac/.gitignore | Removed sandbox ignore file. |
Files not reviewed (1)
- server/deployments/a2a1ac/package-lock.json: Generated file
Suppressed comments (1)
server/src/utils/goPortFinder.ts:23
usedPortListis computed but never used, which adds dead code and makes it unclear which port list is intended to be sent to goportscan.
// Query Database for the used ports
const usedPorts = getUsedPorts();
const usedPortList = usedPorts.map((row: any) => row.port).join(",");
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const binaryPath = path.join(process.cwd(), 'bin', 'goportscan'); | ||
|
|
||
|
|
||
| // TODO: Fix the process.exit instead of exiitng throw an error |
| export function getUsedPorts() { | ||
| const statement = db.prepare("SELECT port FROM deployments WHERE status IN ('deployed', 'deploying') ORDER BY port ASC"); | ||
| return statement.all(); | ||
| } |
| // 3. Docker image built successfully, now find an available port and create a container | ||
| Logger.info(`Docker image built successfully: ${imageName}`); | ||
| const dockerPort = await findAvailablePort(); | ||
| Logger.info(`Available port found for Docker container: ${dockerPort}`); | ||
|
|
Summary by CodeRabbit