Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indicate process ready or failure states by process output pattern match #102

Closed
loganwishartcraig opened this issue Nov 15, 2023 · 3 comments

Comments

@loganwishartcraig
Copy link

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

@thenonameguy
Copy link
Sponsor Contributor

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.

@F1bonacc1
Copy link
Owner

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).

F1bonacc1 added a commit that referenced this issue Nov 18, 2023
@loganwishartcraig
Copy link
Author

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

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

No branches or pull requests

3 participants