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 support for background jobs of indefinite length #512

Open
masukomi opened this issue Jun 27, 2023 · 2 comments
Open

add support for background jobs of indefinite length #512

masukomi opened this issue Jun 27, 2023 · 2 comments
Labels
feature request A new lefthook feature description

Comments

@masukomi
Copy link

⚡ Summary

support background jobs where you don't care how long it takes or if it finishes successfully

Value

Sometimes a git interaction should kick off a process, but you you don't want to have to wait for that process to finish and you don't really care if it finishes successfully.

admittedly silly example:

lolcommits allows you to snap a picture whenever you make a commit. It also allows you to generate N seconds worth of animated gif. If you capture 3 seconds worth of video on every commit, then you'll have to wait an additional 3 seconds for lefthook to finish. Yes, this can be worked around via a wrapper script that bash forks but that's not the point. I'm just trying to give you a simple example and show why it'd be nice to not have to work around the lack of background job support.

Behavior and configuration changes

  • add support for a background: true key and documentation that says that the output of backgrounded tasks will not be considered.
  • indicate that the task has been started like any other
  • fork the process so that the normal lefthook invocation can exit and you can get on with whatever you were doing while the background process runs.
@masukomi masukomi added the feature request A new lefthook feature description label Jun 27, 2023
@mrexox
Copy link
Member

mrexox commented Jun 27, 2023

Sounds good! Thank you for the feature request. Currently I don't have enough resources (time and power) to implement this feature, but if you want to try Go and contribute to the open source project - I'll be glad to help!

@mrexox
Copy link
Member

mrexox commented Mar 15, 2024

By the way, have you considered using & at the end of the command?

long-running:
  commands:
    loong:
      run: sleep 1000 &
lefthook run long-running
╭────────────────────────────────────────╮
│ 🥊 lefthook v1.6.7  hook: long-running │
╰────────────────────────────────────────╯
┃  loong ❯



  ────────────────────────────────────
summary: (done in 0.00 seconds)
✔️   loong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A new lefthook feature description
Projects
None yet
Development

No branches or pull requests

2 participants