diff --git a/deploy_nomad_mcp.py b/deploy_nomad_mcp.py index ad6fd1a..c4697eb 100644 --- a/deploy_nomad_mcp.py +++ b/deploy_nomad_mcp.py @@ -13,9 +13,95 @@ from app.services.nomad_client import NomadService # Load environment variables from .env file load_dotenv() +def check_git_status(): + """Check if there are uncommitted changes in the git repository.""" + try: + # Check for uncommitted changes + result = subprocess.run( + ["git", "status", "--porcelain"], + capture_output=True, + text=True, + check=True + ) + + if result.stdout.strip(): + print("\n⚠️ WARNING: You have uncommitted changes in your repository!") + print("The Nomad job will pull code from Gitea, not your local changes.") + print("Uncommitted files:") + for line in result.stdout.strip().split('\n'): + print(f" - {line}") + + # Check if we're behind the remote + result = subprocess.run( + ["git", "status", "-sb"], + capture_output=True, + text=True, + check=True + ) + + if "behind" in result.stdout: + print("\n⚠️ Your local branch is behind the remote repository!") + print("The deployed code will be from the remote repository, not your local version.") + + print("\nDo you want to:") + print("1. Continue deployment anyway (will use the code in Gitea)") + print("2. Abort to commit and push your changes first") + + choice = input("\nEnter your choice (1 or 2): ").strip() + if choice == "2": + print("\nDeployment aborted. Please commit and push your changes first:") + print(" git add .") + print(" git commit -m \"Your commit message\"") + print(" git push") + sys.exit(0) + elif choice == "1": + print("\nContinuing with deployment using the code in Gitea...") + else: + print("\nInvalid choice. Aborting deployment.") + sys.exit(1) + else: + # Check if we're up to date with remote + result = subprocess.run( + ["git", "status", "-sb"], + capture_output=True, + text=True, + check=True + ) + + if "behind" in result.stdout: + print("\n⚠️ Your local branch is behind the remote repository!") + print("The deployed code will be from the remote repository, not your local version.") + print("Do you want to pull the latest changes before checking? (y/n)") + + choice = input().strip().lower() + if choice == "y": + subprocess.run(["git", "pull"], check=True) + print("Successfully pulled latest changes.") + else: + print("Continuing with deployment using the code in Gitea...") + else: + print("✅ Git repository is clean and up to date with remote.") + except subprocess.CalledProcessError as e: + print(f"\n⚠️ Warning: Failed to check git status: {e}") + print("Unable to verify if all changes are committed and pushed.") + print("Please ensure your code is committed and pushed to Gitea before deploying.") + + print("\nDo you want to continue anyway? (y/n)") + choice = input().strip().lower() + if choice != "y": + print("Deployment aborted.") + sys.exit(0) + except Exception as e: + print(f"\n⚠️ Warning: Error checking git status: {str(e)}") + print("Unable to verify if all changes are committed and pushed.") + print("Please ensure your code is committed and pushed to Gitea before deploying.") + def main(): print("Deploying Nomad MCP service using our own Nomad client...") + # Check git status before deployment + check_git_status() + # Check if NOMAD_ADDR is configured nomad_addr = os.getenv("NOMAD_ADDR") if not nomad_addr: diff --git a/nomad_mcp_job.nomad b/nomad_mcp_job.nomad index 6d85bbb..5746412 100644 --- a/nomad_mcp_job.nomad +++ b/nomad_mcp_job.nomad @@ -43,7 +43,7 @@ job "nomad-mcp" { HOST = "0.0.0.0" # Logging level - LOG_LEVEL = "INFO" + LOG_LEVEL = "DEBUG" # Set to DEBUG for more verbose logging # Enable to make development easier RELOAD = "true"