exec_publish_done
The exec_publish_done directive allows execution of a specified command after a stream has been successfully published in the NGINX RTMP module.
Description
The exec_publish_done directive is utilized within the NGINX RTMP module to execute a specified external command once a successful stream publication has concluded. This functionality is particularly useful for triggering external processes, such as logging, analytics, or other post-publishing tasks relevant to the streaming workflow. The command can be a script or executable that takes the context of the stream as arguments, enabling dynamic interactions post-publication.
Parameters for the exec_publish_done directive can include paths to scripts that need to be run and any arguments that should be passed to those scripts. This is particularly beneficial for live streaming scenarios where actions need to be automated upon the completion of a stream publication. The directive can be specified multiple times, allowing several commands to be queued for execution after publication, thus offering flexibility in handling various use cases.
Upon invocation, the directive interacts directly with the event loop to execute the commands asynchronously, ensuring the main streaming process is not blocked. It’s important to handle external commands carefully to avoid performance bottlenecks. The configuration should also ensure proper resource management to prevent memory leaks or excessive resource usage during high-traffic streaming events.
Config Example
application live {
live on;
exec_publish_done /usr/local/bin/post_publish_script.sh $name;
}Ensure the specified command is available on the server and has executable permissions.
Avoid executing long-running commands to prevent blocking the event loop.
Be cautious with the passing of arguments to external scripts; ensure they are properly escaped if needed.