Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

crivetimihai
Copy link
Member

@crivetimihai crivetimihai commented Jul 27, 2025

Update run-gunicorn.sh script, closes #397 closes #430

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.

@crivetimihai
Copy link
Member Author

crivetimihai commented Jul 27, 2025

Currently fails on docker runs with:

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) duplicate column name: slug
[SQL: ALTER TABLE gateways ADD COLUMN slug VARCHAR]
(Background on this error at: https://sqlalche.me/e/20/e3q8)

@crivetimihai crivetimihai merged commit bf33359 into main Jul 27, 2025
19 of 21 checks passed
@crivetimihai crivetimihai deleted the 397-update-run-gunicorn.sh branch July 27, 2025 14:15
vk-playground pushed a commit to vk-playground/mcp-context-forge that referenced this pull request Sep 14, 2025
* Update run-gunicorn.sh script, closes IBM#397 closes IBM#430

Signed-off-by: Mihai Criveti <[email protected]>

* Remove db migration from script, now part of main code

Signed-off-by: Mihai Criveti <[email protected]>

* Remove db migration from script, now part of main code

Signed-off-by: Mihai Criveti <[email protected]>

---------

Signed-off-by: Mihai Criveti <[email protected]>
vk-playground pushed a commit to vk-playground/mcp-context-forge that referenced this pull request Sep 14, 2025
* Update run-gunicorn.sh script, closes IBM#397 closes IBM#430

Signed-off-by: Mihai Criveti <[email protected]>

* Remove db migration from script, now part of main code

Signed-off-by: Mihai Criveti <[email protected]>

* Remove db migration from script, now part of main code

Signed-off-by: Mihai Criveti <[email protected]>

---------

Signed-off-by: Mihai Criveti <[email protected]>
vk-playground pushed a commit to vk-playground/mcp-context-forge that referenced this pull request Sep 16, 2025
* Update run-gunicorn.sh script, closes IBM#397 closes IBM#430

Signed-off-by: Mihai Criveti <[email protected]>

* Remove db migration from script, now part of main code

Signed-off-by: Mihai Criveti <[email protected]>

* Remove db migration from script, now part of main code

Signed-off-by: Mihai Criveti <[email protected]>

---------

Signed-off-by: Mihai Criveti <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant