Skip to content

Commit

Permalink
Start ExSync manually to ensure it's started if (and only if) Relive
Browse files Browse the repository at this point in the history
  • Loading branch information
badlop committed Aug 21, 2024
1 parent 6110f21 commit db3a5d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 1 addition & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ defmodule Ejabberd.MixProject do
{Mix.env() == :translations,
{:ejabberd_po, git: "https://github.com/processone/ejabberd-po.git"}},
{Mix.env() == :dev,
{:exsync, "~> 0.2"}},
{:exsync, "~> 0.2", optional: true, runtime: false}},
{config(:redis), {:eredis, "~> 1.2.0"}},
{config(:sip), {:esip, "~> 1.0"}},
{config(:zlib), {:ezlib, "~> 1.0"}},
Expand All @@ -183,7 +183,6 @@ defmodule Ejabberd.MixProject do

defp cond_apps do
for {:true, app} <- [{config(:stun), :stun},
{Map.has_key?(System.get_env(), "RELIVE"), :exsync},
{if_version_below(~c"27", true), :jiffy},
{config(:tools), :observer}], do:
app
Expand Down
8 changes: 8 additions & 0 deletions src/ejabberd_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ start(normal, _Args) ->
ejabberd_hooks:run(ejabberd_started, []),
ejabberd:check_apps(),
ejabberd_systemd:ready(),
maybe_start_exsync(),
{T2, _} = statistics(wall_clock),
?INFO_MSG("ejabberd ~ts is started in the node ~p in ~.2fs",
[ejabberd_option:version(),
Expand Down Expand Up @@ -198,8 +199,15 @@ start_elixir_application() ->
ok -> ok;
{error, _Msg} -> ?ERROR_MSG("Elixir application not started.", [])
end.

maybe_start_exsync() ->
case os:getenv("RELIVE") of
"true" -> rpc:call(node(), 'Elixir.ExSync.Application', start, []);
_ -> ok
end.
-else.
setup_if_elixir_conf_used() -> ok.
register_elixir_config_hooks() -> ok.
start_elixir_application() -> ok.
maybe_start_exsync() -> ok.
-endif.

0 comments on commit db3a5d8

Please sign in to comment.