• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

danielberkompas / elasticsearch-elixir / 6d62fb34-9aa7-495e-a6ee-2aa612692ada

15 Sep 2023 03:22AM UTC coverage: 84.644% (-0.4%) from 85.019%
6d62fb34-9aa7-495e-a6ee-2aa612692ada

push

semaphore

danielberkompas
:wrench: Use Config instead of Mix.Config

Mix.Config is deprecated in recent versions of Elixir.

226 of 267 relevant lines covered (84.64%)

551.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/lib/elasticsearch/executable.ex
1
defmodule Elasticsearch.Executable do
2
  @moduledoc """
3
  Wraps an Elasticsearch executable so it can be run as part of the Elixir
4
  supervision tree.
5

6
  See `Mix.Tasks.Elasticsearch.Install` to install Elasticsearch to a directory
7
  for your project.
8

9
  ## Example
10

11
  Add a worker to your supervision tree, like so:
12

13
      worker(Elasticsearch.Executable, [
14
        "Elasticsearch",
15
        "./vendor/elasticsearch/bin/elasticsearch",
16
        9200
17
      ], id: :elasticsearch),
18
  """
19

20
  use GenServer
21

22
  @doc false
23
  def start_link(name, executable, port_number) do
24
    GenServer.start_link(__MODULE__, [name, executable, port_number])
2✔
25
  end
26

27
  @doc false
28
  def init([name, executable, port_number]) do
29
    case System.cmd("lsof", ["-i", ":#{port_number}"]) do
2✔
30
      {"", _} ->
31
        wrap = Application.app_dir(:elasticsearch) <> "/priv/bin/wrap"
2✔
32
        port = Port.open({:spawn, "#{wrap} #{executable} -E http.port=#{port_number}"}, [])
2✔
33
        {:os_pid, os_pid} = Port.info(port, :os_pid)
2✔
34
        IO.puts("[info] Running #{name} with PID #{os_pid} on port #{port_number}")
2✔
35
        {:ok, port}
36

37
      _other ->
38
        IO.puts("[info] Detected #{name} already running on port #{port_number}")
×
39
        {:ok, nil}
40
    end
41
  end
42
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc