exec_push
The exec_push directive in the NGINX RTMP module allows executing external commands in response to certain stream events.
Description
The exec_push directive is designed to trigger external programs or commands whenever specific events related to a stream occur, such as publishing (starting a live stream) or closing a stream. This is particularly useful for integrating additional functionalities, such as transcoding, monitoring, or logging, because it can automate tasks without requiring manual intervention.
A unique aspect of this directive is that it accepts one or more arguments, which represent the commands to be executed. The expected format generally includes the command followed by its parameters. The flexibility of specifying multiple commands allows users to create complex workflows depending on their application's requirements. Each time the relevant stream event occurs, the specified commands will be executed in the context of the NGINX process, allowing for immediate processing.
However, when implementing exec_push, users must be cautious about the commands being run, as misconfiguration could lead to security vulnerabilities or performance issues. For example, long-running processes can block the NGINX worker processes, which could affect streaming performance.
Config Example
application live {
live on;
exec_push /path/to/script.sh arg1 arg2;
}Ensure the external command is carefully controlled to avoid security risks.
Avoid long-running processes in exec_push as they can block the worker processes, affecting the overall performance.
Validate the output of external commands to handle any errors gracefully.