Add map of descriptions for built-in services to reduce startup time #4
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Freedive loads services at startup
state =
state
|> Map.put(:services, list_services!())
def list_services!() do
all_service_names = all_service_names()
enabled_service_names = enabled_service_names()
all_service_names
|> Enum.map(fn name -> service_details!(name, Enum.member?(enabled_service_names, name)) end)
|> Enum.into(%{}, &{&1[:name], &1})
end
def all_service_names() do
case execute(@service_bin, ["-l"]) do
{:ok, stdout} ->
stdout
|> String.split("\n")
|> Enum.map(&String.trim/1)
|> Enum.reject(&Enum.member?(@skip_service_names, &1))
def enabled_service_names() do
case execute(@service_bin, ["-e"]) do
{:ok, stdout} ->
stdout
|> String.split("\n")
|> Enum.map(&String.trim/1)
|> Enum.map(&Path.basename/1)
This can take while if many services are enabled and running. Freedive only loads descriptions for enabled services to prevent long startup times. Descriptions for built-in services can be added as a static map to speed up initial loading time and enusre descriptions are available for all services, and can be displayed in the service list view on tablet/desktop.
Add map of built-in services to reduce startup timeto Add map of descriptions for built-in services to reduce startup time