1%%%------------------------------------------------------------------- 2%% This Source Code Form is subject to the terms of the Mozilla Public 3%% License, v. 2.0. If a copy of the MPL was not distributed with this 4%% file, You can obtain one at https://mozilla.org/MPL/2.0/. 5%% 6%% Copyright (c) 2020-2021 VMware, Inc. or its affiliates. All rights reserved. 7%% 8 9-module(rabbit_boot_state_sup). 10-behaviour(supervisor). 11 12-export([start_link/0, 13 init/1]). 14 15-export([notify_boot_state_listeners/1]). 16 17start_link() -> 18 supervisor:start_link({local, ?MODULE}, ?MODULE, []). 19 20init([]) -> 21 SystemdSpec = #{id => rabbit_boot_state_systemd, 22 start => {rabbit_boot_state_systemd, start_link, []}, 23 restart => transient}, 24 {ok, {#{strategy => one_for_one, 25 intensity => 1, 26 period => 5}, 27 [SystemdSpec]}}. 28 29-spec notify_boot_state_listeners(rabbit_boot_state:boot_state()) -> ok. 30notify_boot_state_listeners(BootState) -> 31 lists:foreach( 32 fun 33 ({_, Child, _, _}) when is_pid(Child) -> 34 gen_server:cast(Child, {notify_boot_state, BootState}); 35 (_) -> 36 ok 37 end, 38 supervisor:which_children(?MODULE)). 39