Skip to content

Conversation

@faraquet
Copy link

@faraquet faraquet commented Oct 23, 2025

Introduces an optional lightweight HTTP server for health checks, integrated with Solid Queue lifecycle.

  • Responds with 200 OK on / and /health; returns 404 otherwise.
  • Useful for container orchestration platforms (Kubernetes, Nomad) and external monitoring.

Configuration:

  • In config/application.rb or an initializer:
    Rails.application.configure do
      config.solid_queue.health_server_enabled = true
      # Optional overrides; defaults read ENV vars:
      # config.solid_queue.health_server_host = "0.0.0.0"
      # config.solid_queue.health_server_port = 9393
    end
  • Defaults:
    • host: ENV["SOLID_QUEUE_HTTP_HOST"] or "0.0.0.0"
    • port: ENV["SOLID_QUEUE_HTTP_PORT"] or 9393

Implementation details:

  • New accessors in SolidQueue: health_server_enabled, health_server_host, health_server_port.
  • New SolidQueue::HealthServer that serves a minimal HTTP response using TCPServer.
  • Engine initializer solid_queue.health_server starts/stops the server via SolidQueue.on_start, on_stop, and on_exit.

Testing notes:

  • With the server enabled, curl http://<host>:<port>/health should return 200 OK and body OK.
  • Verify port binding conflicts by customizing health_server_port if needed.

Backward compatibility:

  • Feature is disabled by default; no behavior changes unless explicitly enabled.

Risks/Mitigations:

  • Minimal footprint; runs in a background thread and closes on stop/exit hooks.
  • Logs under SolidQueueHTTP progname using the existing SolidQueue.logger passed to the server.

Puma plugin

  • When the Puma plugin is active (plugin :solid_queue in puma.rb), Solid Queue will skip starting the health server even if health_server_enabled is set. A warning is logged instead. This prevents running multiple embedded servers in the same process tree.

@faraquet
Copy link
Author

faraquet commented Oct 23, 2025

@rosa could you please have a look? This is a simple and safe change, but I believe it will be useful for many people, including myself.
I'm sure the failing tests are unrelated, as I've seen the same issue in other branches.

Happy to discuss if needed

@Th3-M4jor
Copy link
Contributor

Feel free to disagree with me on this, but what about adding some kind of check to ensure that this can't be run while also using the Puma plugin?

@faraquet
Copy link
Author

Thanks for the hint, @Th3-M4jor 👍

I agree with you and will add an extra check.

@faraquet
Copy link
Author

Added ✅

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