@@ -135,10 +135,56 @@ extract_schema(#plugin{type = dir, location = Location}, SchemaDir) ->
135
135
136
136
% % @doc Lists the plugins which are currently running.
137
137
active () ->
138
- {ok , ExpandDir } = application :get_env (rabbit , plugins_expand_dir ),
139
- InstalledPlugins = plugin_names (list (ExpandDir )),
138
+ LoadedPluginNames = maybe_keep_required_deps (false , loaded_plugin_names ()),
140
139
[App || {App , _ , _ } <- rabbit_misc :which_applications (),
141
- lists :member (App , InstalledPlugins )].
140
+ lists :member (App , LoadedPluginNames )].
141
+
142
+ loaded_plugin_names () ->
143
+ {ok , PluginsDir } = application :get_env (rabbit , plugins_dir ),
144
+ PluginsDirComponents = filename :split (PluginsDir ),
145
+ loaded_plugin_names (code :get_path (), PluginsDirComponents , []).
146
+
147
+ loaded_plugin_names ([Path | OtherPaths ], PluginsDirComponents , PluginNames ) ->
148
+ case lists :sublist (filename :split (Path ), length (PluginsDirComponents )) of
149
+ PluginsDirComponents ->
150
+ case build_plugin_name_from_code_path (Path ) of
151
+ undefined ->
152
+ loaded_plugin_names (
153
+ OtherPaths , PluginsDirComponents , PluginNames );
154
+ PluginName ->
155
+ loaded_plugin_names (
156
+ OtherPaths , PluginsDirComponents ,
157
+ [list_to_atom (PluginName ) | PluginNames ])
158
+ end ;
159
+ _ ->
160
+ loaded_plugin_names (OtherPaths , PluginsDirComponents , PluginNames )
161
+ end ;
162
+ loaded_plugin_names ([], _ , PluginNames ) ->
163
+ PluginNames .
164
+
165
+ build_plugin_name_from_code_path (Path ) ->
166
+ AppPath = case filelib :is_dir (Path ) of
167
+ true ->
168
+ case filelib :wildcard (filename :join (Path , " *.app" )) of
169
+ [AP | _ ] -> AP ;
170
+ [] -> undefined
171
+ end ;
172
+ false ->
173
+ EZ = filename :dirname (filename :dirname (Path )),
174
+ case filelib :is_regular (EZ ) of
175
+ true ->
176
+ case find_app_path_in_ez (EZ ) of
177
+ {ok , AP } -> AP ;
178
+ _ -> undefined
179
+ end ;
180
+ _ ->
181
+ undefined
182
+ end
183
+ end ,
184
+ case AppPath of
185
+ undefined -> undefined ;
186
+ _ -> filename :basename (AppPath , " .app" )
187
+ end .
142
188
143
189
% % @doc Get the list of plugins which are ready to be enabled.
144
190
list (PluginsPath ) ->
0 commit comments