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 on_exit deferring it for all the commands #161

Merged
merged 2 commits into from
Nov 12, 2023
Merged

Conversation

umputun
Copy link
Owner

@umputun umputun commented Nov 11, 2023

The goal is to add a per-task on_exit command that will be invoked on the task's completion on each server. The goal is to allow all kinds of cleanup actions, service restarts, and so on to be in a more logical place.

Currently, it is possible to add some cleanup commands, but for larger tasks, it is hard to follow, and having it right in the command should make it easier.

For example:

task:
  - name: "copy script"
    copy: {src: "testdata/script.sh", "dst": "/tmp/script.sh", "chmod+x": true}
    on_exit: "rm -fv /tmp/script.sh" # register deferred action to remove script.sh after execution

  - name: "run script"
    script: "/tmp/script.sh"

Here, we "register" the removal of /tmp/script.sh. This is somewhat similar to Go's deffer running the command on function completion, but in the case of Spot, it runs on task completion instead and on each remote server.

Copy link

cloudflare-pages bot commented Nov 12, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1c8221e
Status: ✅  Deploy successful!
Preview URL: https://ed0241ea.spot-7ki.pages.dev
Branch Preview URL: https://on-exit.spot-7ki.pages.dev

View logs

@umputun umputun merged commit d143c0e into master Nov 12, 2023
4 checks passed
@umputun umputun deleted the on_exit branch November 12, 2023 18:56
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.

None yet

1 participant