elixir - 安装 Ejabberd 模块不会启动底层依赖
问题描述
我正在尝试在 Ejabberd 中运行自定义 elixir 插件,以将 SQS 消息发送到某些 Ejabberd 挂钩的队列(使用 ex_aws 库)。但是,当我使用并触发 ejabberd 钩子将插件安装到 Ejabberd 时mix module_install plugin_name
,ex_aws 依赖项似乎没有启动。
我的 mix.exs 文件:
defmodule PluginName.Mixfile do
use Mix.Project
def project do
[
app: :plugin_name,
version: "0.2.0",
elixir: "~> 1.8",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps(),
test_coverage: [tool: ExCoveralls],
preferred_cli_env: [
"coveralls": :test,
"coveralls.detail": :test,
"coveralls.post": :test,
"coveralls.html": :test
],
dialyzer: [
flags: [:error_handling, :race_conditions]
]
]
end
def application do
[extra_applications: [:logger, :amqp, :ex_aws, :ex_aws_sts, :ex_aws_sqs]]
end
defp deps do
[
{:sweet_xml, "~> 0.6"},
{:configparser_ex, "~> 4.0"},
{:saxy, "~> 1.1"},
{:ex_aws, "~> 2.1"},
{:ex_aws_sts, "~> 2.1"},
{:ex_aws_sqs, "~> 3.2"},
{:hackney, "~> 1.9"},
{:credo, "~> 0.8", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.0.0-rc.6", only: [:dev], runtime: false},
{:excoveralls, "~> 0.7", only: :test},
{:mock, "~> 0.3.3", only: :test},
{:amqp, "~> 1.1.1"},
{:poison, "~> 3.1"},
{:reunion, git: "https://github.com/snar/reunion", branch: "master", runtime: false},
{:ejabberd, git: "redacted", branch: "master", runtime: false},
{:xmpp, "~> 1.3.0"}
]
end
end
我看到的错误消息:
2021-03-01 22:40:30.105 [error] <0.1206.0>@Elixir.ExAws.Config.AuthCache:get:20 gen_server sqs_client terminated with reason: bad argument in call to ets:lookup('Elixir.ExAws.Config.AuthCache', aws_instance_auth) in 'Elixir.ExAws.Config.AuthCache':get/1 line 20
2021-03-01 22:40:30.105 [error] <0.1206.0>@Elixir.ExAws.Config.AuthCache:get:20 CRASH REPORT Process sqs_client with 0 neighbours crashed with reason: bad argument in call to ets:lookup('Elixir.ExAws.Config.AuthCache', aws_instance_auth) in 'Elixir.ExAws.Config.AuthCache':get/1 line 20
2021-03-01 22:40:30.108 [error] <0.2520.0>@ejabberd_hooks:safe_apply:384 Hook offline_message_hook crashed when running 'Elixir.PluginName':on_offline_msg/1:
** Reason = {exit,{{badarg,[{ets,lookup,['Elixir.ExAws.Config.AuthCache',aws_instance_auth],[]},{'Elixir.ExAws.Config.AuthCache',get,1,[{file,"lib/ex_aws/config/auth_cache.ex"},{line,20}]},{'Elixir.ExAws.Config',retrieve_runtime_value,2,[{file,"lib/ex_aws/config.ex"},{line,84}]},{'Elixir.Stream','-map/2-fun-0-',4,[{file,"lib/stream.ex"},{line,495}]},{'Elixir.Enumerable.List',reduce,3,[{file,"lib/enum.ex"},{line,3080}]},{'Elixir.Enumerable.Stream',do_each,4,[{file,"lib/stream.ex"},{line,1405}]},{'Elixir.Enum',find,3,[{file,"lib/enum.ex"},{line,868}]},{'Elixir.ExAws.Config','-retrieve_runtime_config/1-fun-0-',2,[{file,"lib/ex_aws/config.ex"},{line,71}]}]},{'Elixir.GenServer',call,[sqs_client,{publish_sqs,<<redacted>>},5000]}},[{'Elixir.GenServer',call,3,[{file,"lib/gen_server.ex"},{line,737}]},{'Elixir.PluginName',on_offline_msg,1,[{file,"lib/plugin_name.ex"},{line,161}]},{ejabberd_hooks,safe_apply,4,[{file,"src/ejabberd_hooks.erl"},{line,381}]},{ejabberd_hooks,run_fold1,4,[{file,"src/ejabberd_hooks.erl"},{line,365}]},{maps,fold_1,3,[{file,"maps.erl"},{line,232}]},{mod_muc_room,process_groupchat_message,2,[{file,"src/mod_muc_room.erl"},{line,798}]},{p1_fsm,handle_msg,10,[{file,"src/p1_fsm.erl"},{line,582}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,249}]}]}
我曾尝试Application.ensure_all_started(:ex_aws)
在插件的 start() 方法中使用,但这并不能解决问题。
解决方案
推荐阅读
- javascript - Fabric JS - 移动、缩放和旋转时在自定义边界外剪裁文本
- r - 根据两个条件填充 geom_point():在列值上,或者如果值为 0
- c++ - 使用 GetDefaultCommConfig 时出现无效参数错误
- html - 添加 div 导致图像消失
- python - How to add an \n in txt when meet Specified word in python
- python-3.x - Python - 根据另一个数据集的列值过滤数据集
- vim - 在vim中,如何突出显示用户定义的数据类型?
- mysql - 如何在具有逗号分隔的 int 值的列上使用 group_concat 时获得唯一的结果?
- javascript - 我无法在屏幕上打印列表
- ios - Xcode 显示不需要的语法错误