-
Notifications
You must be signed in to change notification settings - Fork 31
/
browser_sup.ex
32 lines (27 loc) · 1009 Bytes
/
browser_sup.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
defmodule WebDriver.BrowserSup do
use Supervisor
@moduledoc """
The WebDriver.BrowserSup is a supervisor responsible for overseeing
the running of browser instances and their associated session supervisors.
If a browser crashes for any reason this will restart the browser and the
sessions that connect to it. Of course those sessions will have lost their
state.
"""
@browsers [ firefox: WebDriver.Firefox.Port,
phantomjs: WebDriver.PhantomJS.Port,
chrome: WebDriver.Chrome.Port,
remote: WebDriver.Remote.Port ]
@doc """
Starts up a browser. The browser is then
responsible for starting a session supervisor attached to this
supervisor.
"""
def start_link config do
:supervisor.start_link __MODULE__, config
end
def init config do
child_processes = [ worker(Keyword.get(@browsers, config.browser),
[config, self])]
supervise child_processes, strategy: :rest_for_one
end
end