You've already forked algora-tv
							
							
				mirror of
				https://github.com/algora-io/tv.git
				synced 2025-10-30 23:07:56 +02:00 
			
		
		
		
	Use dynamic supervisor instead of FLAME local backend (#127)
This commit is contained in:
		| @@ -28,6 +28,8 @@ defmodule Algora.Application do | ||||
|       {Task.Supervisor, name: Algora.TaskSupervisor}, | ||||
|       # Start the supervisor for tracking manifest uploads | ||||
|       {DynamicSupervisor, strategy: :one_for_one, name: Algora.Pipeline.Storage.ManifestSupervisor}, | ||||
|       # Start the supervisor for rtmp to hls pipeline | ||||
|       {DynamicSupervisor, strategy: :one_for_one, name: Algora.Pipeline.Supervisor}, | ||||
|       # Start the RPC server | ||||
|       {Fly.RPC, []}, | ||||
|       # Start the Ecto repository | ||||
| @@ -39,15 +41,17 @@ defmodule Algora.Application do | ||||
|       # Start the Telemetry supervisor | ||||
|       AlgoraWeb.Telemetry, | ||||
|       # Pipeline flame pool | ||||
|       {FLAME.Pool, | ||||
|         name: Algora.Pipeline.Pool, | ||||
|         backend: Algora.config([:flame_backend]), | ||||
|         min: Algora.config([:flame, :min]), | ||||
|         max: Algora.config([:flame, :max]), | ||||
|         max_concurrency: Algora.config([:flame, :max_concurrency]), | ||||
|         idle_shutdown_after: Algora.config([:flame, :idle_shutdown_after]), | ||||
|         log: Algora.config([:flame, :log]), | ||||
|       }, | ||||
|       if Algora.config([:flame, :backend]) != FLAME.LocalBackend do | ||||
|         {FLAME.Pool, | ||||
|           name: Algora.Pipeline.Pool, | ||||
|           backend: Algora.config([:flame_backend]), | ||||
|           min: Algora.config([:flame, :min]), | ||||
|           max: Algora.config([:flame, :max]), | ||||
|           max_concurrency: Algora.config([:flame, :max_concurrency]), | ||||
|           idle_shutdown_after: Algora.config([:flame, :idle_shutdown_after]), | ||||
|           log: Algora.config([:flame, :log]), | ||||
|         } | ||||
|       end, | ||||
|       # Start the PubSub system | ||||
|       {Phoenix.PubSub, name: Algora.PubSub}, | ||||
|       # Start presence | ||||
|   | ||||
| @@ -24,7 +24,11 @@ defmodule Algora.Pipeline.Manager do | ||||
|         {:ok, pid} | ||||
|       else | ||||
|         _ -> | ||||
|           FLAME.place_child(Algora.Pipeline.Pool, {__MODULE__, [self(), params]}) | ||||
|           if Algora.config([:flame, :backend]) == FLAME.LocalBackend do | ||||
|             Algora.Pipeline.Supervisor.start_child([self(), params]) | ||||
|           else | ||||
|             FLAME.place_child(Algora.Pipeline.Pool, {__MODULE__, [self(), params]}) | ||||
|           end | ||||
|       end | ||||
|  | ||||
|     {Algora.Pipeline.ClientHandler, %{pipeline: pid}} | ||||
|   | ||||
							
								
								
									
										21
									
								
								lib/algora/pipeline/supervisor.ex
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								lib/algora/pipeline/supervisor.ex
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| defmodule Algora.Pipeline.Supervisor do | ||||
|   use DynamicSupervisor | ||||
|  | ||||
|   def resume_rtmp(pipeline, params) when is_pid(pipeline) do | ||||
|     GenServer.call(pipeline, {:resume_rtmp, params}) | ||||
|   end | ||||
|  | ||||
|   def start_link(init_arg) do | ||||
|     DynamicSupervisor.start_link(__MODULE__, init_arg, name: __MODULE__) | ||||
|   end | ||||
|  | ||||
|   def start_child(init_arg) do | ||||
|     spec = Supervisor.child_spec({Algora.Pipeline.Manager, init_arg}, restart: :transient) | ||||
|     DynamicSupervisor.start_child(__MODULE__, spec) | ||||
|   end | ||||
|  | ||||
|   @impl true | ||||
|   def init(init_arg) do | ||||
|     DynamicSupervisor.init(strategy: :simple_one_for_one, extra_arguments: [init_arg]) | ||||
|   end | ||||
| end | ||||
		Reference in New Issue
	
	Block a user