-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication.ex
More file actions
39 lines (34 loc) · 1.07 KB
/
Copy pathapplication.ex
File metadata and controls
39 lines (34 loc) · 1.07 KB
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
33
34
35
36
37
38
39
# SPDX-License-Identifier: MPL-2.0
# Copyright (c) Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
defmodule ScriptManager.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
@impl true
def start(_type, _args) do
if web_disabled?() do
opts = [strategy: :one_for_one, name: ScriptManager.Supervisor]
Supervisor.start_link([], opts)
else
# Ensure directories exist
ScriptManager.WebApp.ensure_directories()
children = [
# Start the web interface when the application starts
{Task, fn -> ScriptManager.WebApp.start() end}
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: ScriptManager.Supervisor]
Supervisor.start_link(children, opts)
end
end
defp web_disabled? do
case System.get_env("SCRIPT_MANAGER_DISABLE_WEB") do
"1" -> true
"true" -> true
"TRUE" -> true
_ -> false
end
end
end