Stop Agent after current job

Is it possible to stop the agent, but not with killing the currently running build job, but instead wait until that currently running job has completed?

Consider a scenario in which a workflow is running, and multiple others are enqueued. If I stop the agent using ctrl+c, the currently running job will fail and it’s workflow, and not picked up by the agent when I start it again. I’d have to manually re-run the failed pipeline.

What I would like is to send a signal to the agent to complete the current job and then terminate. So that the next time I start the agent, it will pick up all remaining enqueued pipelines, including the one that hasn’t been finished.

When you say agent can you provide a little more background as CircleCI has a number of ‘agents’ that operate in different environments - ‘Self-hosted runner (Dedicated System/VM)’, ‘Container runner (Kube)’, and their hosted on-demand offering.

None of their offerings have any published way of providing the level of control you are looking for as when operating they are just polling the work queue. The ‘Self-hosted runner’ does support the idea of being run via some form of third-party executor so can be operated in a single task or idle timeout modes, but these do not match what you are looking for.

Hey, thanks for your insights and sorry for my late reply (I didn’t get an update notification).

True I totally forgot to mention our environment. We’re using a self-hosted runner on a Windows PC, namely circleci-launch-agent.exe.

A single-task mode would sound interesting indeed - can the agent be started to execute one job only? This way we could wrap it into an abortable script, which checks an abort flag after every execution.

Yes, the agent can be set to run a single task, by adding a line to its config file.

The setting is runner.mode

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.