<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>... having said that, I do have a little erlang program I run as an escript in a tmux session.</div><div><br></div><div>Ivan<br><br>--<br>festina lente<div><br></div></div><div><br>On 21 Oct 2013, at 13:09, Michael Scofield <<a href="mailto:bayinamine@gmail.com">bayinamine@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div>
  

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  
  
    Hi all! I'm new to erlang for a few month. <br>
    <br>
    Recently I've developed a small pure erlang program, and it runs
    well in the shell. Now I want to run it in the background, as a
    daemon service process in the os (mine is Ubuntu 12.04 64bit with
    R16B). So I googled "run erlang without shell", and google gave me
    some advice:<br>
    <br>
    1. Using escript. -This is what erlang official faq suggested (
    <meta http-equiv="content-type" content="text/html;
      charset=ISO-8859-1">
    <a href="http://www.erlang.org/faq/how_do_i.html">http://www.erlang.org/faq/how_do_i.html</a>).
    <br>
    2. erl -detached -s Module Function Args<br>
    <br>
    I tried both. As to #1, my escript goes to<br>
    <br>
    #!/usr/bin/env escript<br>
    main(_) -><br>
      my_supervisor:start_link(arg1, arg2).<br>
    <br>
    I ran it using "nohup ./my-escript &", and it didn't run my
    code. =(<br>
    <br>
    So I went to #2. I was acknowledged that "-s" can only pass 0 or 1
    argument, so I wrapped my supervisor using<br>
    <br>
    -module(run).<br>
    -export([start/0]).<br>
    <br>
    start() -><br>
      my_supervisor:start_link(arg1, arg2).<br>
    <br>
    and ran my code as "erl -detached -s run start". But this was also a
    dead end. <br>
    <br>
    I guessed it's because the run:start/0 just returned and finished
    the shell(Is it?), so I added a line to the run:start/0:<br>
    <br>
    -module(run).<br>
    -export([start/0]).<br>
    <br>
    start() -><br>
      my_supervisor:start_link(arg1, arg2),<br>
      <b>receive after infinity -> stop end.</b><br>
    <br>
    And executed "erl -detached -s run start", and everything goes fine!
    my_supervisor started to work without the shell!<br>
    <br>
    Though the problem "solved", I'm very very confused.<br>
    1. Why the "magic line" solved my problem?<br>
    2. What exactly is the proper or right way to run an erlang
    application in the background as the command "nohup ... &" does?<br>
    <br>
    Thanks in advance!<br>
    <br>
    Michael<br>
  

</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>erlang-questions mailing list</span><br><span><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a></span><br><span><a href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a></span><br></div></blockquote></body></html>