How can I create an exixic escript that does not stop the Erlang VM after execution (e.g. elixir --no-halt)

I have a program that launches an application and then adds (children) to the supervisor. Obviously, after doing all this, he has nothing more to do, and he stops (exits). Therefore, so that he did not stop the virtual machine, the workers could work.

The only solution I chose is to add:

IO.gets "Working... To finish hit <Enter>."

in the end...

I want to build escript, which after starting will not stop the Erlang VM in the same way as:

elixir --no-halt -S mix run --eval 'MyApp.CLI.m
ain(["some-arg"])'

or

mix run --no-halt --eval 'MyApp.CLI.m
ain(["some-arg1,some-arg2"])'

Is there a way to do this with escript?

Or do I need to use another solution to package and distribute my program, which actually looks more like a server / daemon than a command line tool?

+4
2

OTP. exrm .

- escript, :timer.sleep(:infinity) .

+6

: Elixir 1.9

System.no_halt(true), .

:

defmodule Mix.Tasks.NoHalt do
  use Mix.Task

  def run(_) do
    System.no_halt(true)
    IO.puts("Never die!")
  end
end
+1

All Articles