Eventum Logo

Eventum

Eventtemplate

Subprocess

Execute shell commands from Jinja2 templates.

The subprocess variable lets you execute shell commands from templates.

NameTypeDefaultConstraintsDescription
commandstringShell command to execute.
cwdstringNoneWorking directory.
envmappingNoneEnvironment variables.
timeoutfloat30.0Up to 300.0Timeout in seconds. A value that is not positive counts as omitted.

The run method returns a result object with three fields:

FieldTypeDescription
stdoutstringStandard output (decoded as UTF-8).
stderrstringStandard error (decoded as UTF-8).
exit_codeintProcess exit code.
{%- set result = subprocess.run('hostname', timeout=5.0) -%}
{{ result.stdout | trim }}

Limits

Commands run under fixed ceilings, so one template cannot stall the whole application or exhaust its memory:

  • Every call is bounded by a timeout — the requested one, 30 seconds when none is given, and 300 seconds at the most. A command that runs longer is terminated together with the processes it started.
  • Each output stream is captured up to 8 MiB. A command that writes more is terminated as well.

In both cases the event is not produced and the reason is written to the generator log.

Subprocess calls run synchronously and block event production. Use short timeouts to avoid stalling the pipeline.

On this page