Opensource Hosting Platform Wiki
Open-source hosting platform for servers, billing and support.
Brought to you by:
autobotsolution
This guide covers all procedures for running and managing the HostingCo development servers.
The HostingCo system consists of multiple development servers:
# From project root - starts both frontend and backend
npm run dev
# This runs:
# - npm run dev:backend (port 3003)
# - npm run dev:frontend (port 3000)
# Start backend only
npm run dev:backend
# Start frontend only
npm run dev:frontend
# Start in separate terminals for independent control
# Start all services with Docker Compose
docker-compose up
# Start specific services
docker-compose up backend frontend
# Development with Docker
docker-compose -f docker-compose.yml up
# Check if servers are running
curl -s http://localhost:3000 > /dev/null && echo "Frontend: RUNNING" || echo "Frontend: STOPPED"
curl -s http://localhost:3003/api/health > /dev/null && echo "Backend: RUNNING" || echo "Backend: STOPPED"
# Check database connection (if using local PostgreSQL)
pg_isready -h localhost -p 5432 -U hostingco
# Check Redis connection (if using local Redis)
redis-cli ping
# Backend logs (if running with npm)
tail -f backend/logs/combined.log
tail -f backend/logs/error.log
# Frontend logs (Vite output)
# Logs appear in the terminal where npm run dev:frontend is running
# Docker logs
docker-compose logs -f backend
docker-compose logs -f frontend
Port: 3003 (configurable via PORT environment variable)
Features:
Environment Variables:
NODE_ENV=development
PORT=3003
DATABASE_URL=postgresql://hostingco:password@localhost:5432/hostingco
REDIS_URL=redis://localhost:6379
FRONTEND_URL=http://localhost:3000
JWT_SECRET=dev-secret-key
Port: 3000 (configurable via Vite)
Features:
Configuration (vite.config.ts):
export default defineConfig({
server: {
port: 3000,
proxy: {
'/api': {
target: 'http://localhost:3003',
changeOrigin: true
}
}
}
})
# 1. Start development servers
npm run dev
# 2. In separate terminal, watch for changes
npm run test:watch
# 3. Make code changes
# 4. Servers auto-reload
# 5. Test changes in browser
# Create new migration
cd backend
npm run migration:generate -- --name add_new_feature
# Run migrations
npm run migrate
# Rollback migration
npm run migrate:rollback
# Reset database
npm run db:reset
# Run all tests
npm test
# Run backend tests
npm run test:backend
# Run frontend tests
npm run test:frontend
# Watch mode
npm run test:watch
# Generate coverage report
npm run test:coverage
# View coverage in browser
open coverage/lcov-report/index.html
# Start with Node.js debugger
npm run dev:debug
# Or with VS Code launch configuration
# Use .vscode/launch.json configuration
VS Code Launch Configuration (.vscode/launch.json):
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Backend",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/backend/src/index.ts",
"outFiles": ["${workspaceFolder}/backend/dist/**/*.js"],
"runtimeArgs": ["-r", "ts-node/register"],
"env": {
"NODE_ENV": "development"
},
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
# Check TypeScript compilation
cd backend && npx tsc --noEmit
# Check ESLint errors
npm run lint
# Fix ESLint errors
npm run lint:fix
# Check package dependencies
npm audit
npm audit fix
# Monitor backend performance
curl -w "@curl-format.txt" -o /dev/null -s http://localhost:3003/api/health
# Monitor frontend build performance
# Vite shows build times in terminal
# Memory usage
node --inspect backend/dist/index.js
# Check slow queries
psql -h localhost -U hostingco -d hostingco -c "
SELECT query, mean_time, calls, total_time
FROM pg_stat_statements
ORDER BY mean_time DESC
LIMIT 10;"
# Check database size
psql -h localhost -U hostingco -d hostingco -c "
SELECT pg_size_pretty(pg_database_size('hostingco'));"
# Install pre-commit hooks
npm run setup:hooks
# Pre-commit runs:
# - ESLint
# - TypeScript compilation check
# - Unit tests
# Use curl for quick API testing
curl -X GET http://localhost:3003/api/health
curl -X POST http://localhost:3003/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"test@example.com","password":"password"}'
# Or use API client like Postman/Insomnia
# Import collection from docs/api-collection.json
# Check what's using ports
ss -tlnp | grep -E ":300[03]"
# Kill processes
sudo kill -9 <PID>
# Or change ports in .env files
# Clear TypeScript cache
rm -rf backend/node_modules/.cache
npm run dev
# Check TypeScript version
npx tsc --version
# Update TypeScript if needed
npm install typescript@latest
# Clear Vite cache
rm -rf frontend/node_modules/.vite
npm run dev:frontend
# Clear all caches
npm run clean
npm install
npm run dev
# Check PostgreSQL status
sudo systemctl status postgresql
# Restart PostgreSQL
sudo systemctl restart postgresql
# Reset database
cd backend
npm run db:reset
.env.example as template.env files# Weekly
npm audit fix
npm update
# Monthly
npm outdated
npm install -g npm@latest
# As needed
npm cache clean --force
rm -rf node_modules package-lock.json
npm install
# Rotate logs (weekly)
logrotate -f /etc/logrotate.d/hostingco
# Clean old logs
find backend/logs -name "*.log" -mtime +30 -delete
# Vacuum database (weekly)
psql -h localhost -U hostingco -d hostingco -c "VACUUM ANALYZE;"
# Update statistics
psql -h localhost -U hostingco -d hostingco -c "ANALYZE;"
Last updated: $(date)