From 06f2a2bc29995b3356d12f5006d8f0bb0ce32043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 31 Oct 2023 10:17:16 +0100 Subject: [PATCH] Rename `cli` command to `exec` and document it The `cli` word, to me, implies too much that it's run via a shell, which it isn't. Renaming to `exec` resolves that. --- CHANGELOG.md | 1 + internal/worker/command_exe.go | 2 +- .../{command_cli.go => command_exec.go} | 16 ++++++------ .../usage/jobs-tasks-commands/commands.md | 25 +++++++++++++++++++ 4 files changed, 35 insertions(+), 9 deletions(-) rename internal/worker/{command_cli.go => command_exec.go} (80%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e360f44..31fbde1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ bugs in actually-released versions. - Database integrity tests. These are always run at startup of Flamenco Manager, and by default run periodically every hour. This can be configured by adding/changing the `database_check_period: 1h` setting in `flamenco-manager.yaml`. Setting it to `0` will disable the periodic check. When a database consistency error is found, Flamenco Manager will immediately shut down. - Workers can be marked as 'restartable' by using the `-restart-exit-code N` commandline option. More info in the [Worker Actions documentation](https://flamenco.blender.org/usage/worker-actions/). - Worker name can be configured via `flamenco_worker.yaml` via `worker_name = "somename"`. +- Add worker command `exec` for executing arbitrary executables. - Upgrade bundled FFmpeg from 5.0 to 5.1. - Rename the add-on download to `flamenco-addon.zip` (it used to be `flamenco3-addon.zip`). It still contains the same files as before, and in Blender the name of the add-on has not changed. - Improve speed of queueing up >100 simultaneous job deletions. diff --git a/internal/worker/command_exe.go b/internal/worker/command_exe.go index a13a2314..e78b36ae 100644 --- a/internal/worker/command_exe.go +++ b/internal/worker/command_exe.go @@ -81,7 +81,7 @@ func NewCommandExecutor(cli CommandLineRunner, listener CommandListener, timeSer // misc "echo": ce.cmdEcho, "sleep": ce.cmdSleep, - "cli": ce.cmdCLI, + "exec": ce.cmdExec, // blender "blender-render": ce.cmdBlenderRender, diff --git a/internal/worker/command_cli.go b/internal/worker/command_exec.go similarity index 80% rename from internal/worker/command_cli.go rename to internal/worker/command_exec.go index 5b2a3aac..e72ef898 100644 --- a/internal/worker/command_cli.go +++ b/internal/worker/command_exec.go @@ -14,17 +14,17 @@ import ( "projects.blender.org/studio/flamenco/pkg/api" ) -type CliParams struct { +type ExecParams struct { exe string // Executable to run. args []string // Arguments for the executable. } -// cmdCLI runs an arbitrary executable with arguments. -func (ce *CommandExecutor) cmdCLI(ctx context.Context, logger zerolog.Logger, taskID string, cmd api.Command) error { +// cmdExec runs an arbitrary executable with arguments. +func (ce *CommandExecutor) cmdExec(ctx context.Context, logger zerolog.Logger, taskID string, cmd api.Command) error { cmdCtx, cmdCtxCancel := context.WithCancel(ctx) defer cmdCtxCancel() - execCmd, err := ce.cmdCLICommand(cmdCtx, logger, taskID, cmd) + execCmd, err := ce.cmdExecCommand(cmdCtx, logger, taskID, cmd) if err != nil { return err } @@ -43,13 +43,13 @@ func (ce *CommandExecutor) cmdCLI(ctx context.Context, logger zerolog.Logger, ta return nil } -func (ce *CommandExecutor) cmdCLICommand( +func (ce *CommandExecutor) cmdExecCommand( ctx context.Context, logger zerolog.Logger, taskID string, cmd api.Command, ) (*exec.Cmd, error) { - parameters, err := cmdCLIParams(logger, cmd) + parameters, err := cmdExecParams(logger, cmd) if err != nil { return nil, err } @@ -70,9 +70,9 @@ func (ce *CommandExecutor) cmdCLICommand( return execCmd, nil } -func cmdCLIParams(logger zerolog.Logger, cmd api.Command) (CliParams, error) { +func cmdExecParams(logger zerolog.Logger, cmd api.Command) (ExecParams, error) { var ( - parameters CliParams + parameters ExecParams ok bool ) diff --git a/web/project-website/content/usage/jobs-tasks-commands/commands.md b/web/project-website/content/usage/jobs-tasks-commands/commands.md index b64d290d..55d603c7 100644 --- a/web/project-website/content/usage/jobs-tasks-commands/commands.md +++ b/web/project-website/content/usage/jobs-tasks-commands/commands.md @@ -62,6 +62,31 @@ Copies a file from one location to another. | `src` | `string` | Path of the file to copy. Must be an absolute path. | | `dest` | `string` | Destination to copy it to. Must be an absolute path. This path may not yet exist. | +## Misc: `exec` + +Run an executable. This can be any executable. The command succeeds when the +executable exit status is `0`, and fails otherwise. The executable needs to stop +running (or fork) in order for the Worker to consider the command 'done'. + +The executable is run directly, and *not* via a shell invocation. To run a shell +command, use something like `{exe: "/bin/bash", args: ["-c", "echo", "hello +world"]}`. + + +{{< hint type=info >}} +If there is a specific command for the functionality you need, like +`blender-render` or `ffmpeg`, use those commands instead. They are aware of +cross-platform differences, and know more about the program they are running. +For example, the `blender-render` command sends rendered images to the Manager +to show in the web interface, and `ffmpeg` will change its commandline arguments +depending on the platform it runs on. +{{< /hint >}} + +| Parameter | Type | Description | +|-----------|------------|------------------------| +| `exec` | `string` | The executable to run. | +| `args` | `[]string` | Commandline arguments. | + ## Misc: `echo` Writes a message to the task log.