F1bonacc1/process-compose

Indicate process ready or failure states by process output pattern match

Closed this issue · 3 comments

Feature Request

Use Case:

I have a couple build processes that watch files and rebuild, they don't setup any server, but they do write some "SUCCESS" message to stdout.

Would be cool if I could define something in the .yaml file to match against a pattern for indicating ready/failure

Proposed Change:

An extension to readiness_probe allowing something like an stdout regex match.

Who Benefits From The Change(s)?

People who's process doesn't expose a health check endpoint, but still would like to use readiness to kick off other processes.

Alternative Approaches

This might be implementable by exec currently? Might just need a recipe to show how it could work

The readiness_probe.exec route is the way to go. Define a log file location for the process and use grep on it to check for the predicate to match.

Hi @loganwishartcraig,

You can probably (not sure what is the exact output of your watcher) achieve this with the following configuration:

processes:
  watcher:
    command: "sleep 1 && echo SUCCESS && sleep 9"
    log_location: ./watcher.log
    readiness_probe:
      exec:
        command: "grep -q SUCCESS ./watcher.log"
      initial_delay_seconds: 1
      period_seconds: 1
      timeout_seconds: 1
      success_threshold: 1

  wait4it:
    command: "echo watcher is healthy"
    depends_on:
      watcher:
        condition: process_healthy

But...
If SUCCESS is the only thing that your process prints AND it doesn't exit, the log will be buffered and the readiness_probe.exec won't catch it.

If that's an issue I can add a flag to the process configuration, to flush the log on each line (default false).

Hey both - forgot to follow up here. Thanks for taking the time to respond! Will explore that approach.