fleetcode/START_SERVER.md

2.1 KiB

🚀 Start FleetCode Web Server

Quick Start

# 1. Enter Nix development environment
nix develop

# 2. Install dependencies (first time only)
npm install

# 3. Start the web server
npm run server

Access the Application

From This Machine

http://localhost:3000

From Network (LAN)

Your server will be accessible at:

http://192.168.1.240:3000

From Internet

See WEB_SERVER_SETUP.md for remote access options.

Server Commands

# Default port (3000)
npm run server

# Custom port
PORT=8080 npm run server

# Build only (without starting)
npm run build

What's Running?

  • HTTP Server: Express on port 3000 (or custom PORT)
  • WebSocket: Socket.IO for real-time terminal communication
  • Static Files: Serves index.html and compiled assets
  • Terminal Backend: node-pty for terminal session management

Stopping the Server

Press Ctrl+C in the terminal where the server is running.

Troubleshooting

"Port already in use"

# Use different port
PORT=8080 npm run server

# Or find and kill process using port 3000
lsof -ti:3000 | xargs kill -9

"Cannot find module" errors

# Reinstall dependencies
npm install

# Rebuild native modules for Node.js
npm rebuild node-pty --update-binary

Can't access from network

# Check firewall (NixOS)
sudo iptables -L | grep 3000

# Temporarily open port
sudo iptables -A INPUT -p tcp --dport 3000 -j ACCEPT

Next Steps

  1. Server is running locally
  2. 📱 Access from your phone/tablet on same network: http://192.168.1.240:3000
  3. 🌍 Set up remote access (see WEB_SERVER_SETUP.md)
  4. 🔐 Add authentication before exposing to internet
  5. 🔒 Configure HTTPS with reverse proxy

Files Created

  • server.ts - Web server implementation
  • WEB_SERVER_SETUP.md - Detailed setup guide
  • flake.nix - Updated with web server commands

Architecture

Browser (Any Device)
    ↓ HTTP/WebSocket
Express Server (port 3000)
    ↓ Socket.IO
Terminal Sessions (node-pty)
    ↓
Git Worktrees + Claude/Codex

Enjoy FleetCode! 🎉