<p dir="ltr">Look at erlexec instead. open_port is not designed for lifetime management like that.</p>
<div class="gmail_quote">On Sep 16, 2013 7:31 AM, "pablo platt" <<a href="mailto:pablo.platt@gmail.com">pablo.platt@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div>I looked at erlsh. It uses open_port with a loop like I'm using in my code so my question still stands.<br></div></div>Why I'm not getting the exit message from the "docker run" command?<br>
<br><div>erldocker looks nice but I couldn't find the equivalent of "docker
run" without starting, attaching, detaching and destroying a container.<br></div>I'm not sure how to do it manually because I need to know when the container exits which docker run does.<br></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Mon, Sep 16, 2013 at 3:26 PM, Maxim Sokhatsky <span dir="ltr"><<a href="mailto:maxim@synrc.com" target="_blank">maxim@synrc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>First of all you do it wrong just because of two things :)<br>
<br>
The first thing is erlsh library: <a href="https://github.com/proger/erlsh" target="_blank">https://github.com/proger/erlsh</a><br>
And the second is erldocker library: <a href="https://github.com/proger/erldocker" target="_blank">https://github.com/proger/erldocker</a><br>
<br>
</div>Moreover if you are interesting in your own Erlang PaaS<br>
<div>you could read the sources of the first Erlang PaaS:<br>
<br>
<a href="https://github.com/voxoz" target="_blank">https://github.com/voxoz</a><br>
<br>
Hope this save your time :)<br>
<br>
/maxim<br>
<br>
________________________________<br>
> Date: Mon, 16 Sep 2013 15:10:48 +0300<br>
> From: <a href="mailto:pablo.platt@gmail.com" target="_blank">pablo.platt@gmail.com</a><br>
> To: <a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
> Subject: [erlang-questions] Not getting exit_status when using<br>
> open_port with docker<br>
><br>
</div><div><div>> Hi,<br>
><br>
> I'm calling "docker run" from Erlang.<br>
> <a href="http://docs.docker.io/en/latest/commandline/command/run/" target="_blank">http://docs.docker.io/en/latest/commandline/command/run/</a><br>
> I'm using open_port instead of os:cmd to be able to limit the execution time.<br>
> I'm getting the output of the command<br>
> but the do_read just keep going and I'm not able to get an exit status<br>
> from the command.<br>
><br>
> When running "echo 'test'" I'm getting {exit_status, 0}.<br>
> When running the "docker run" command in the shell, I'm getting the<br>
> output and it exits.<br>
> When running any other docker command like "docker ps" I'm getting the<br>
> exit signal.<br>
><br>
> Is this a problem with how I'm using open_port or something wrong with<br>
> the "docker run" command?<br>
><br>
> -module(test).<br>
><br>
> -export([run/0]).<br>
><br>
> run() -><br>
> Cmd = "sudo docker run ubuntu echo \"test\"",<br>
> Port = open_port({spawn, Cmd}, [binary, exit_status]),<br>
> do_read(Port, <<>>).<br>
><br>
> do_read(Port, Data) -><br>
> receive<br>
> {Port,{data, NewData}} -><br>
> io:format("data ~p~n", [NewData]),<br>
> do_read(Port, <<Data/binary, NewData/binary>>);<br>
> {Port,{exit_status, 0}} -><br>
> io:format("exit~n"),<br>
> case Data of<br>
> <<"">> -> <<"ok">>;<br>
> _ -> Data<br>
> end;<br>
> E -><br>
> io:format("Something: ~p~n", [E])<br>
> end.<br>
><br>
><br>
</div></div><div><div>> _______________________________________________ erlang-questions<br>
> mailing list <a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div>