I have erlang application: *.app file and some *.erl files. I compile all of them. In terminal i start erl and there application:start(my_application).
, all ok, but if i closed terminal application close too. How can i run application without terminal depending?
Thank you.
On a Unix system you enter the command erl at the operating system prompt. This command starts the Erlang runtime system and the Erlang shell. On the Windows platform you normally start Erlang/OTP from the start menu. You can also enter the command erl or werl from a DOS box or Command box.
Well if you're in the shell of the node you want to turn down, even if it's not receiving input, you can still press Ctrl-g (which takes you to JCL mode). Once there you can use the command q to quit the Erlang shell. This is similar in effect to erlang:halt(0).
Erlang is a programming language used to build massively scalable soft real-time systems with requirements on high availability. Some of its uses are in telecoms, banking, e-commerce, computer telephony and instant messaging.
You likely want to use the -noshell
option to erl
. The syntax is
erl -noshell -s Module Function Arguments
So in your case, this might be
erl -noshell -s application start my_application
This should allow you (for example if you are on Unix/Linux) to start your application as a background process and leave it running.
One useful variation is to also call the stop/0
function of the init
module so that the Erlang environment will stop when it has finished running your function. This comes in handy if you want to run a simple one-use function and pipe the output to some other process.
So, for example, to pipe to more
you could do
erl -noshell -s mymodule myfunction -s init stop | more
Finally, you might also be able to use the escript
command to run your Erlang code as scripts rather than compiled code if it makes sense for your situation.
Hope that helps.
The proper way to handle this situation, is building a release containing your app and running the system as so called embedded one. This release is going to be completely independent (it will hold erts and all the libs like, kernel, std, mnesia etc.). On start, the new process will not be connected to shell process. It will be OS process, so you can attach to it with pipes. All script are included in OTP. Here is some info: http://www.erlang.org/doc/design_principles/release_structure.html It may seem to be complicated, but tools like rebar do everything for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With