- Bootstrap 4 - Rendering the dashboard with Vue.js instead of constructing the HTML with jQuery.
Flamenco Manager
This is the Flamenco Manager implementation in Go.
Author: Sybren A. Stüvel sybren@blender.studio
Getting started
To run Flamenco Manager for the first time, follow these steps:
- Install ImageMagick and make sure that the
convertcommand can be found on$PATH. - Download Flamenco Manager for your platform.
- Extract the downloaded file.
- Run
./flamenco-manager -setup(Linux/macOS) orflamenco-manager.exe -setup(Windows). - Flamenco Manager will give you a list of URLs at which it can be reached. Open the URL that is reachable both for you and the workers.
- Link Flamenco Manager to Blender Cloud by following the steps in the web interface.
- Configure Flamenco Manager via the web interface. Update the variables and path replacement
variables for your render farm; the
blendervariable should point to the Blender executable where it can be found on the workers, and similar for theffmpegvariable. The path replacement variables allow you to set different paths for both Clients (like the Blender Cloud Add-on) and Workers, given their respective platforms. - Once you have completed configuration, restart Flamenco Manager through the web interface. It will now run in normal (i.e. non-setup) mode.
Note that variables and path_replacement share a namespace -- variable names have to be unique,
and cannot be used in both variables and path_replacement sections. If this happens, Flamenco
Manager will log the offending name, and refuse to start.
Advanced Configuration
Apart from the above web-based setup, you can configure advanced settings by editing
flamenco-manager.yaml. For example, you can:
- Generate TLS certificates and set the path in the
tlskeyandtlscertconfiguration options. Transport Layer Security (TLS) is the we-are-no-longer-living-in-the-90ies name for SSL. - Set intervals for various periodic operations. See
flamenco-manager-example.yamlfor a description.
Intervals (like download_task_sleep) can be configured in seconds, minutes, or hours, by appending
a suffix s, m, or h. Such a suffix must always be used.
CLI arguments
Flamenco Manager accepts the following CLI arguments:
-setup: Start in setup mode, which will enable the web-based setup on the/setupURL.-debug: Enable debug-level logging-verbose: Enable info-level logging (no-op if-debugis also given). This is automatically enabled in setup mode.-json: Log in JSON format, instead of plain text-cleanslate: Start with a clean slate; erases all cached tasks from the local MongoDB, then exits Flamenco Manager. This can be run while another Flamenco Manager is running, but this scenario has not been well-tested yet.-purgequeue: Erases all queued task updates from the local MongoDB, then exits Flamenco Manager. NOTE: this is a lossy operation, and it may erase important task updates. Only perform this when you know what you're doing.
Running as service via systemd (Linux-only)
- Build (see below) and configure Flamenco Manager.
- Edit
flamenco-manager.serviceto update it for the installation location, then place the file in/etc/systemd/system. - Run
systemctl daemon-reloadto pick up on the new/edited file. - Run
systemctl start flamenco-managerto start Flamenco Manager. - Run
systemctl enable flamenco-managerto ensure it starts at boot too.
Starting development
$FM denotes the directory containing a checkout of Flamenco Manager, that is, the absolute path
of this flamenco-manager directory.
- Make sure you have MongoDB up and running (on localhost)
- Install Go 1.9 or newer
export GOPATH=/path/to/your/workspace/for/gocd $FM- Install "dep" with
go get -u github.com/golang/dep/cmd/dep - Download all dependencies with
dep ensure - Download Flamenco test dependencies with
go get -t ./... - Run the unittests with
go test ./... - Build your first Flamenco Manager with
go install; this will create an executableflamenco-managerin$GOPATH/bin. It may be a good idea to add$GOPATH/binto yourPATHenvironment variable. - Configure Flamenco Manager by starting it in setup mode (
flamenco-manager -setup, see above). - Run the Manager with
$GOPATH/bin/flamenco-manager -verbose.
Testing
To run all unit tests, run go test ./... -v. To run a specific GoCheck test, run
go test ./flamenco -v --run TestWithGocheck -check.f SchedulerTestSuite.TestVariableReplacement
where the argument to --run determines which suite to run, and -check.f determines the
exact test function of that suite. Once all tests have been moved over to use GoCheck, the
--run parameter will probably not be needed any more.
Communication between Server and Manager
Flamenco Manager is responsible for initiating all communication between Server and Manager, since Manager should be able to run behind some firewall/router, without being reachable by Server.
In the text below, some_fields can refer to configuration file settings.
Fetching tasks
- When a Worker ask for a task, it is served a task in state
queuedorclaimed-by-managerin the local task queue (MongoDB collection "flamenco_tasks"). In this case, Manager performs a conditional GET (based on etag) to Server at /api/flamenco/tasks/{task-id} to see if the task has been updated since queued. If this is so, the task is updated in the queue and the queue is re-examined. - When the queue is empty, the manager fetches new tasks from the Server. This is also done when one clicks the "Kick task downloader" button in the dashboard.
Task updates and canceling running tasks
- Pushes happen as POST to "/api/flamenco/managers/{manager-id}/task-update-batch"
- Task updates queued by workers are pushed every
task_update_push_max_interval, or whentask_update_push_max_countupdates are queued, whichever happens first. - An empty list of task updates is pushed every
cancel_task_fetch_max_interval, unless an actual push (as described above) already happened within that time. - The response to a push contains the database IDs of the accepted task updates, as well as a list of task database IDs of tasks that should be canceled. If this list is non-empty, the tasks' statuses are updated accordingly.
Timeouts of active tasks
When a worker starts working on a task, that task moves to status "active". The worker then
regularly calls /may-i-run/{task-id} to verify that it is still allowed to run that task. If this
end-point is not called within active_task_timeout_interval_seconds seconds, it will go to status
"failed". The default for this setting is 60 seconds, which is likely to be too short, so please
configure it for your environment.
This timeout check will start running 5 minutes after the Manager has started up. This allows workers to let it know they are still alive, in case the manager was unreachable for longer than the timeout period. For now this startup delay is hard-coded.
Missing features / future work
In no particular order:
- GZip compression on the pushes to Server. This is especially important for task updates, since they contain potentially very large log entries.
- A way for Flamenco Server to get an overview of Workers, and set their status.
Building distributable packages
The distributable Flamenco Manager packages are built using Docker. This allows us to build a static binary without impacting the locally installed version of Go. The process is as follows:
- Install Docker Community Edition.
cdinto thedockerdirectory.- Prepare the bundled MongoDB server files:
- Download MongoDB for Linux (the "legacy" build), Windows (the "2008 and later without SSL" version), and MacOS (the version without SSL). Versions without SSL support are used because they're simpler and we listen on localhost anyway so SSL is not necessary.
- Extract the files you downloaded (the Windows version may require
msiextractfrom themsitoolspackage if you're extracting on Linux). - Make sure the contents can be found in
docker/mongodb-{linux,osx,windows}-version, so the Linuxbindirectory should be indocker/mongodb-{linux,osx,windows}-version/bin. - Remove everything from the
bindirectories exceptmongod(ormongod.exefor the Windows version).
- Run
./build-via-docker.shto create the distributable packages.