Skip to content

Commit

Permalink
try code:load_file if loading with code:ensure_loaded fails
Browse files Browse the repository at this point in the history
ensure_loaded fails if our code server is in embedded mode.
  • Loading branch information
Andrei Zavada committed Jun 21, 2021
1 parent 9066933 commit b445a6d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/riak_kv_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,20 @@ start(_Type, _StartArgs) ->
%% Check the storage backend
StorageBackend = app_helper:get_env(riak_kv, storage_backend),
case code:ensure_loaded(StorageBackend) of
{error,nofile} ->
lager:critical("storage_backend ~p is non-loadable.",
[StorageBackend]),
{error, embedded} ->
case code:load_file(StorageBackend) of
{error, LoadReason} ->
lager:critical("storage_backend ~p is non-loadable: ~p.",
[StorageBackend, LoadReason]),
throw({error, invalid_storage_backend});
{module, _} ->
ok
end;
{error, EnsureReason} ->
lager:critical("storage_backend ~p is non-loadable: ~p.",
[StorageBackend, EnsureReason]),
throw({error, invalid_storage_backend});
_ ->
{module, _} ->
ok
end,

Expand Down

0 comments on commit b445a6d

Please sign in to comment.