Skip to content
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.

Implement rabbitmqctl hipe_compile #179

Merged
merged 5 commits into from
Mar 14, 2017
Merged

Implement rabbitmqctl hipe_compile #179

merged 5 commits into from
Mar 14, 2017

Conversation

michaelklishin
Copy link
Member

@michaelklishin michaelklishin commented Mar 10, 2017

Originally introduced in rabbitmq/rabbitmq-server#808.

Fixes #178.

This command needs access to RabbitMQ modules and currently
propagation doesn't work as expected.
This correctly handles the case where the rabbit app is
already loaded.

References #178.
def validate(_, _), do: {:validation_failure, :too_many_args}

def run([target_dir], _opts) do
case Application.load(:rabbit) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to do Application.load again?
It should be called during validation.

{:error, {:already_loaded, :rabbit}} ->
Code.ensure_loaded(:rabbit_hipe)
hipe_compile(target_dir)
:ok;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An error message from the previous line will never be shown.

defp hipe_compile(target_dir) do
case :rabbit_hipe.can_hipe_compile() do
true ->
{:ok, _, _} = :rabbit_hipe.compile_to_directory(target_dir)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ok, already_compiled} will not be matched.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally, it won't be returned, because compile_to_directory will clean the directory before compiling, but the code is in different repo and the change can easily slip through the cracks.

@hairyhum
Copy link
Contributor

Empty string for directory crashes the command

scripts/rabbitmqctl hipe_compile ''
Will pre-compile RabbitMQ server modules with HiPE to  ...
Error: 
function_clause
 Stacktrace [{lists,last,[[]],[{file,"lists.erl"},{line,228}]},
             {rabbit_file,filename_as_a_directory,1,
                 [{file,"src/rabbit_file.erl"},{line,306}]},
             {rabbit_hipe,compile_to_directory,1,
                 [{file,"src/rabbit_hipe.erl"},{line,40}]},
             {'Elixir.RabbitMQ.CLI.Ctl.Commands.HipeCompileCommand',
                 hipe_compile,1,
                 [{file,
                      "lib/rabbitmq/cli/ctl/commands/hipe_compile_command.ex"},
                  {line,69}]},
             {'Elixir.RabbitMQ.CLI.Ctl.Commands.HipeCompileCommand',run,2,
                 [{file,
                      "lib/rabbitmq/cli/ctl/commands/hipe_compile_command.ex"},
                  {line,48}]},
             {'Elixir.RabbitMQCtl',maybe_run_command,3,
                 [{file,"lib/rabbitmqctl.ex"},{line,157}]},
             {'Elixir.RabbitMQCtl','-exec_command/2-fun-0-',5,
                 [{file,"lib/rabbitmqctl.ex"},{line,72}]},
             {'Elixir.RabbitMQCtl',main,1,
                 [{file,"lib/rabbitmqctl.ex"},{line,39}]}]

@hairyhum hairyhum merged commit fb5be56 into master Mar 14, 2017
@gerhard gerhard deleted the rabbitmq-cli-178 branch April 13, 2017 11:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants