Skip to content

b12901

  • b12901
  • 2868ee9
  • Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
  • Choose a tag to compare

  • b12901
  • 2868ee9
  • Choose a tag to compare

  • Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
@ServeurpersoCom ServeurpersoCom tagged this 01 Dec 13:12
* server: add background tasks to the built-in tools

exec_shell_command can now run a command in the background
(background: true), for dev servers, builds or downloads. The call
returns right away with a task id, and the task keeps running until it
exits or is stopped.

Tasks belong to the conversation of the X-Conversation-Id header. The
model manages its own with the new background_task tool, the UI
follows them on /tools/tasks/events, and nothing is left running when
the server exits.

* server: let a running command move to the background

Every exec_shell_command now runs as a task its call waits for, and
sends its exec_id first. POST /tools/tasks with from_exec_id moves it
to the background: the call returns at once and the command keeps
running under the same id. With detach_on_timeout, a command that
reaches its timeout goes to the background instead of being killed.

* server: read whether a task is attached without the registry lock

An exec waiting for its task checked it from inside the output read,
under the output lock, while moving a task to the background takes the
registry lock first and then reads the output size. ThreadSanitizer
reported the lock order inversion.

* doc, nits: follow the naming and comment rules for tasks, document them

tools_task_status values are upper case and prefixed, like the other
server enums, and comments no longer split a sentence over two lines.
README-dev.md describes the background tasks of the /tools API.

* server: address review from ngxson

A background command now runs attached for background_after_seconds
(default 1) and then moves to the background; one that ends before
returns like any other command. This replaces both the fixed 1 s wait
of background: true and detach_on_timeout.

A background command has no timeout, and a command moved to the
background loses its own. The code already did this, now the tool
description, the README and the tests say so.

When the client leaves during that wait, a background command still
moves to the background instead of being stopped.

Task ids are random, so a client can not guess the tasks of another
conversation.
Assets 2
Loading