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.
This commit is contained in:
Sybren A. Stüvel 2023-10-31 10:17:16 +01:00
parent 5dd3939969
commit 06f2a2bc29
4 changed files with 35 additions and 9 deletions

@ -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.

@ -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,

@ -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
)

@ -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.