Cleanup: worker, move FFmpeg-finding at startup into its own file
Just a move of code from `main.go` to a dedicated file in the same package. No functional changes
This commit is contained in:
parent
fb5501028d
commit
377583c9e2
23
cmd/flamenco-worker/find_exes.go
Normal file
23
cmd/flamenco-worker/find_exes.go
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/fs"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"git.blender.org/flamenco/internal/find_ffmpeg"
|
||||
)
|
||||
|
||||
// findFFmpeg tries to find FFmpeg, in order to show its version (if found) or a warning (if not).
|
||||
func findFFmpeg() {
|
||||
result, err := find_ffmpeg.Find()
|
||||
switch {
|
||||
case errors.Is(err, fs.ErrNotExist):
|
||||
log.Warn().Msg("FFmpeg could not be found on this system, render jobs may not run correctly")
|
||||
case err != nil:
|
||||
log.Warn().Err(err).Msg("there was an unexpected error finding FFmepg on this system, render jobs may not run correctly")
|
||||
default:
|
||||
log.Info().Str("path", result.Path).Str("version", result.Version).Msg("FFmpeg found on this system")
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/signal"
|
||||
@ -21,7 +20,6 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"git.blender.org/flamenco/internal/appinfo"
|
||||
"git.blender.org/flamenco/internal/find_ffmpeg"
|
||||
"git.blender.org/flamenco/internal/worker"
|
||||
"git.blender.org/flamenco/internal/worker/cli_runner"
|
||||
)
|
||||
@ -259,16 +257,3 @@ func logFatalManagerDiscoveryError(err error, discoverTimeout time.Duration) {
|
||||
log.Fatal().Err(err).Msg("auto-discovery error")
|
||||
}
|
||||
}
|
||||
|
||||
// findFFmpeg tries to find FFmpeg, in order to show its version (if found) or a warning (if not).
|
||||
func findFFmpeg() {
|
||||
result, err := find_ffmpeg.Find()
|
||||
switch {
|
||||
case errors.Is(err, fs.ErrNotExist):
|
||||
log.Warn().Msg("FFmpeg could not be found on this system, render jobs may not run correctly")
|
||||
case err != nil:
|
||||
log.Warn().Err(err).Msg("there was an unexpected error finding FFmepg on this system, render jobs may not run correctly")
|
||||
default:
|
||||
log.Info().Str("path", result.Path).Str("version", result.Version).Msg("FFmpeg found on this system")
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,13 @@ type CheckBlenderResult struct {
|
||||
Source api.BlenderPathSource
|
||||
}
|
||||
|
||||
// Find returns the path of a `blender` executable,
|
||||
// If there is one associated with .blend files, and the current platform is
|
||||
// supported to query those, that one is used. Otherwise $PATH is searched.
|
||||
func Find(ctx context.Context) (CheckBlenderResult, error) {
|
||||
return CheckBlender(ctx, "")
|
||||
}
|
||||
|
||||
// FileAssociation returns the full path of a Blender executable, by inspecting file association with .blend files.
|
||||
// `ErrNotAvailable` is returned if no "blender finder" is available for the current platform.
|
||||
func FileAssociation() (string, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user