F1bonacc1 / process-compose

Process Compose is a simple and flexible scheduler and orchestrator to manage non-containerized applications.
https://f1bonacc1.github.io/process-compose/
Apache License 2.0
1.33k stars 52 forks source link

Dynamic port number for readines_probe when using multiple replicas #277

Open functoria opened 1 week ago

functoria commented 1 week ago

Hi, I'm starting multiple replicas of the same web server process using the PC_REPLICA_NUM to inject the listening port number:

  my-web-app:
    replicas: 2
    command: |
      java -jar \
          -Dspring.profiles.active= \
          -Dspring.config.location=${APP_CONFIG_FILE} \
          -Dserver.port=808$$PC_REPLICA_NUM \
          -Xms${APP_MEM_XMS} \
          -Xmx${APP_MEM_XMX} \
          -Xss${APP_MEM_XSS} \
          ${APP_BINARY}
    availability:
      restart: on_failure

while the interpolation in the above case seems to work, when I'm trying to use the same variable for the readiness_probe, The PC_REPLICA_NUM variable is no longer correctly interpolated:

readiness_probe:
      http_get:
        host: 127.0.0.1
        scheme: http
        path: "/api/management/health"
        port: 808$$PC_REPLICA_NUM  # <---What should I use here?
      initial_delay_seconds: 5
      period_seconds: 5
      timeout_seconds: 20
      success_threshold: 1
      failure_threshold: 3

and the process is terminated because the probe doesn't use the correct port.

Update: I've tried several interpolation patterns with no success and it looks like the actual value of PC_REPLICA_NUM variable is not available for readiness_probe or liveness_probe interpolation (always empty). Is this by design?