Skip to content

[CHORE]: Migrate run-gunicorn-v2.sh to run-gunicorn.sh and have a single file (improved startup script with configurable flags) #397

@crivetimihai

Description

@crivetimihai

Title: Enhanced run-gunicorn.sh with process locking, dev mode, and improved production features

Description:

Enhance the run-gunicorn.sh script with several production-ready features and developer conveniences:

New Features:

  • Process Lock Protection: Prevents accidental duplicate instances via PID file checking (/tmp/mcpgateway-gunicorn.lock)
  • Developer Mode: Hot reload support with GUNICORN_DEV_MODE=true - automatically enables --reload and watches config files
  • Application Preloading: Memory optimization with GUNICORN_PRELOAD_APP=true for production deployments
  • Auto Worker Detection: Dynamically calculates optimal worker count based on CPU cores (2×CPU+1)
  • Database Init Control: Skip DB initialization with SKIP_DB_INIT=true for faster restarts
  • Force Start Option: Override lock check with FORCE_START=true when needed

Improvements:

  • Added --forwarded-allow-ips="*" for proxy/Kubernetes deployments
  • Enhanced error handling with descriptive messages and recovery suggestions
  • Proper signal handling and cleanup on exit
  • Python 3.x verification to prevent Python 2 usage
  • Comprehensive environment variable documentation

Environment Variables:
All existing vars preserved, plus:

  • GUNICORN_DEV_MODE - Enable hot reload for development
  • GUNICORN_PRELOAD_APP - Preload app for memory savings
  • SKIP_DB_INIT - Skip database initialization
  • FORCE_START - Force start despite existing instance

This makes the script suitable for both development (with hot reload) and production (with preloading, process protection) while maintaining backward compatibility.

Metadata

Metadata

Assignees

Labels

choreLinting, formatting, dependency hygiene, or project maintenance chorescicdIssue with CI/CD process (GitHub Actions, scaffolding)devopsDevOps activities (containers, automation, deployment, makefiles, etc)triageIssues / Features awaiting triage

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions