Gracefully restarting agent at end of build

I have a use case where I would need to ensure that an agent picks up metadata changes made over the course of one build so that it has those changes before the next build is processed:

  • Build is requested
  • Pipeline runs build on appropriate agent.
  • Build modifies the agent’s metadata tags by updating the file in which they are stored.
  • Agent is restarted at the completion of the (successful) build, to ensure that the updated metadata is in
    effect for subsequent builds.

Is there some clean way of doing this sort of thing? I kind of feel like it might not be but wanted to ask here in case I’m wrong about that.

Hey @johnf! Updating the agent tags (metadata) and then restarting the agent is certainly possible :tada:

Once you’ve changed the tags, send a SIGTERM to the agent process which will instruct the agent to gracefully shut down at the end of the build. This relies on running the agent with something that will restart it. This is the default for most Linux installations using systemd.

You can find more information about signal handling in our documentation :green_book:

Thanks Grant!