Skip to content

Dispatch option on gunicorn version#143

Merged
nsoranzo merged 1 commit intogalaxyproject:mainfrom
mvdbeek:revert_no_control_socket
Feb 24, 2026
Merged

Dispatch option on gunicorn version#143
nsoranzo merged 1 commit intogalaxyproject:mainfrom
mvdbeek:revert_no_control_socket

Conversation

@mvdbeek
Copy link
Copy Markdown
Member

@mvdbeek mvdbeek commented Feb 23, 2026

dev is now using a gunicorn version below 25.1.0, so this flag doesn't exist

@mvdbeek mvdbeek changed the title Revert no control socket Revert no-control-socket gunicorn option Feb 23, 2026
@nsoranzo
Copy link
Copy Markdown
Member

How I didn't think about that? 🙄

What about checking the gunicorn version?

diff --git a/gravity/state.py b/gravity/state.py
index deb96e7..7aa7e1c 100644
--- a/gravity/state.py
+++ b/gravity/state.py
@@ -104,6 +104,19 @@ class ConfigFile(BaseModel):
                 exec(fh.read(), {}, locs)
                 return locs["VERSION"]
 
+    @property
+    def gunicorn_version(self):
+        if galaxy_installed:
+            from gunicorn import __version__
+            return __version__
+        else:
+            galaxy_requirements_file = os.path.join(self.galaxy_root, "requirements.txt")
+            with open(galaxy_requirements_file) as fh:
+                for line in fh:
+                    if line.startswith("gunicorn=="):
+                        return line.split("==")[1].strip()
+            raise RuntimeError("gunicorn version not found in Galaxy requirements.txt")
+
     @field_validator("galaxy_root", mode="after")
     def _galaxy_root_required(cls, value: Optional[str], info: ValidationInfo) -> Optional[str]:
         if value is None:
@@ -317,7 +330,7 @@ class GalaxyGunicornService(Service):
     def command_template(self):
         template = self._command_template
         try:
-            if Version(self.config.galaxy_version) >= Version("26.1.0.dev0"):
+            if Version(self.config.gunicorn_version) >= Version("25.1.0"):
                 template += " --no-control-socket"
         except Exception:
             pass

@mvdbeek
Copy link
Copy Markdown
Member Author

mvdbeek commented Feb 23, 2026

gravity doesn't need to be installed in same venv, so I think this would be a step back in the isolation and goals we set out for gravity initially ... but maybe that's ok ?

@nsoranzo
Copy link
Copy Markdown
Member

gravity doesn't need to be installed in same venv, so I think this would be a step back in the isolation and goals we set out for gravity initially ... but maybe that's ok ?

It uses the same pattern of the galaxy_version property.

@mvdbeek
Copy link
Copy Markdown
Member Author

mvdbeek commented Feb 23, 2026

Which does this:

    @property
    def galaxy_version(self):
        if galaxy_installed:
            return galaxy.version.VERSION
        else:
            assert self.galaxy_root is not None
            galaxy_version_file = os.path.join(self.galaxy_root, "lib", "galaxy", "version.py")
            with open(galaxy_version_file) as fh:
                locs: Dict[str, Any] = {}
                exec(fh.read(), {}, locs)
                return locs["VERSION"]

where galaxy_installed is:

try:
    import galaxy.version
    galaxy_installed = True
except ImportError:
    galaxy_installed = False

so that doesn't require same env

@mvdbeek
Copy link
Copy Markdown
Member Author

mvdbeek commented Feb 23, 2026

I should start reading the diff to the end ...

@mvdbeek mvdbeek force-pushed the revert_no_control_socket branch from 0e6a9e8 to 240b10e Compare February 24, 2026 10:00
Much better fix, thank you Nicola!
@mvdbeek mvdbeek force-pushed the revert_no_control_socket branch from 240b10e to c6e5fb5 Compare February 24, 2026 10:03
@nsoranzo nsoranzo changed the title Revert no-control-socket gunicorn option Dispatch option on gunicorn version Feb 24, 2026
Copy link
Copy Markdown
Member

@nsoranzo nsoranzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 😆

@nsoranzo nsoranzo merged commit 463030f into galaxyproject:main Feb 24, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants