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

Add a pre- and post- hook for the process-compose wrapper #56

Merged
merged 2 commits into from
Jan 19, 2024

Conversation

johnalotoski
Copy link
Contributor

  • Allow prep and cleanup scripts, cmds or other customizations in the wrapper with pre- and post- process-compose hooks.
  • The exec of the process-compose call line was removed to allow for a postHook.

Copy link
Member

@srid srid left a comment

Choose a reason for hiding this comment

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

Curious what prompted this?

I considered adding a preHook equivalent (see initCommand commit in #55) but decided against doing it in favour of adding another one-off process which other processes can have a depends_on relation on. This way you get to see the output in the UI as well.

@johnalotoski
Copy link
Contributor Author

johnalotoski commented Jan 19, 2024

What prompted the hook use was wanting to use shell variables obtained and/or set at runtime.

The simplest case was just wanting to use ${TMPDIR:=/tmp} as the base for a short postgres socket path which is then used in several process-compose processes, including postgres-init from services-flake.

When I first tried setting this as a process environment var in each process where it was needed, it evaluated it correctly in most places, but it fails to evaluate correctly in the probe commands, and then processes fails because the probes fail, the postgres ready probe in this case.

Using the hook approach with the shell var declared at the wrapper script level worked.

Here is an example preHook: link.

Example command for this process-compose stack (will download about ~1 GiB binaries, start syncing a public testnet Cardano chain, and extract chain data into postgres for analysis). Nix >= 2.17.0 and experimental-features = fetch-closure required:
nix run github:input-output-hk/cardano-parts/next-2024-01-10#run-process-compose-dbsync-sanchonet

@srid
Copy link
Member

srid commented Jan 19, 2024

Cool, that makes sense. Nice to see the cardano project using this!

@srid srid merged commit c894220 into Platonic-Systems:main Jan 19, 2024
1 check 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