[erlang-questions] ErlExec stdin and other questions

OvermindDL1 <>
Thu Aug 8 09:16:42 CEST 2013


I actually already left an issue on Github with such an example script
yesterday, and system information.  :-)
On Aug 7, 2013 9:15 PM, "Serge Aleynikov" <> wrote:

> I
> am currently on vacation but will try to look into this some time later
> next week when I return.
>
> The stdout/stderr redirection to Erlang is not yet "production" quality -
> rather an experimental feature introduced last week. I am also working on
> adding stdin support, so that you could send messages to an OS process's
> stdin. This should also be available in a week after I return.
>
> As far as I know erlexec is used in several production systems, and except
> for the stdout/stderr redirection to Erlang is stable.
>
> Upon exiting the VM, the erl-exec port process started by exec application
> receives an end-of-file on the stdin pipe, and sets off the alarm, which
> guarantees that it'll be killed after a timeout if it hasn't finished the
> cleanup (termination) of managed processes.  If you don't observe that
> behavior, please provide more information regarding OS you are running, and
> ideally some simple test cases.
>
>
> On Wed, Aug 7, 2013 at 3:36 AM, OvermindDL1 <> wrote:
>
>> Created a complete test-case example of my issue with erlexec, and I ran
>> this same script on 3 different computers running variations of debian
>> versions.  Feel free to toss in application:start(sasl), at the top of the
>> erlang script area if you wish, and yes the (minecraft) server software
>> uses stderr instead of stdout, no I do not know why, and yes as you can see
>> it does not return anything to the erlang system until it is killed on all
>> the systems I tested.  Using Erlang's ports you get each line as a message
>> as that is how the server flushes it and it is instant.
>>
>>
>> Yes it is ugly, but it is pared down from what it grew from and no need
>> to re-do the receive's better in such a test.
>> test_exec_mc.sh
>> """
>> #!/bin/sh
>>
>> [ -d erlexec ] || git clone https://github.com/saleyn/erlexec.git
>>
>> cd erlexec
>>
>> rebar compile
>>
>> [ -f 'minecraft_server.1.6.2.jar' ] || wget '
>> https://s3.amazonaws.com/Minecraft.Download/versions/1.6.2/minecraft_server.1.6.2.jar
>> '
>>
>> erl -pa $PWD/ebin -eval '
>> application:start(exec),
>> {_, P, _} = exec:run_link("java -Xms1G -Xmx1G -jar
>> minecraft_server.1.6.2.jar nogui", [{stdout, self()}, {stderr, self()}]),
>> timer:sleep(1000),
>> receive A0 -> io:format("Message ~p: ~p~n", [now(), A0]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A1 -> io:format("Message ~p: ~p~n", [now(), A1]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A2 -> io:format("Message ~p: ~p~n", [now(), A2]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A3 -> io:format("Message ~p: ~p~n", [now(), A3]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A4 -> io:format("Message ~p: ~p~n", [now(), A4]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> timer:sleep(1000),
>> receive A5 -> io:format("Message ~p: ~p~n", [now(), A5]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A6 -> io:format("Message ~p: ~p~n", [now(), A6]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A7 -> io:format("Message ~p: ~p~n", [now(), A7]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A8 -> io:format("Message ~p: ~p~n", [now(), A8]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A9 -> io:format("Message ~p: ~p~n", [now(), A9]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> timer:sleep(10000),
>> receive A10 -> io:format("Message ~p: ~p~n", [now(), A10]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A11 -> io:format("Message ~p: ~p~n", [now(), A11]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A12 -> io:format("Message ~p: ~p~n", [now(), A12]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A13 -> io:format("Message ~p: ~p~n", [now(), A13]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A14 -> io:format("Message ~p: ~p~n", [now(), A14]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> exec:kill(P, 9),
>> receive A15 -> io:format("Message ~p: ~p~n", [now(), A15]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A16 -> io:format("Message ~p: ~p~n", [now(), A16]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A17 -> io:format("Message ~p: ~p~n", [now(), A17]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A18 -> io:format("Message ~p: ~p~n", [now(), A18]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A19 -> io:format("Message ~p: ~p~n", [now(), A19]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> timer:sleep(1000),
>> receive A20 -> io:format("Message ~p: ~p~n", [now(), A20]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A21 -> io:format("Message ~p: ~p~n", [now(), A21]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A22 -> io:format("Message ~p: ~p~n", [now(), A22]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A23 -> io:format("Message ~p: ~p~n", [now(), A23]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> receive A24 -> io:format("Message ~p: ~p~n", [now(), A24]) after 1000 ->
>> io:format("timeout ~p~n", [now()]) end,
>> q().'
>> """
>>
>>
>>
>>
>>
>> On Tue, Aug 6, 2013 at 10:49 PM, OvermindDL1 <>wrote:
>>
>>> Excepting this, is there any other better way to launch a program as
>>> another user?  I might just use ssh certs and ssh to localhost if not
>>> unless any other ideas?
>>>
>>>
>>> On Tue, Aug 6, 2013 at 4:22 AM, OvermindDL1 <>wrote:
>>>
>>>> I have been attempting to use ErlExec as I noticed that it had a few
>>>> new features added six days ago to forward the stdout/stderr to an Erlang
>>>> PID, however I am having some issue.  The process that erlexec runs
>>>> occasionally does not die when the Erlang VM dies, thus keeping it and its
>>>> children running.
>>>>
>>>> Also I need a way to send commands back to the children, but I am
>>>> either not seeing a command for that or have not figured out the format to
>>>> send a message, which is difficult because of the main issue I have, when I
>>>> have it launch a fairly large server software (that is not a daemon for
>>>> whatever reason, hence why I am wrapping it), the Erlang shell seems to
>>>> lose a great deal of input that I type in, only catching from every 1 in 4
>>>> I type to 1 in 400 characters I type, and it does not seem to matter based
>>>> on the speed I hit keys or holding a key or anything of the sort, just
>>>> purely on keypress down, and it remains like that until I kill the child
>>>> process that I started through erlexec.
>>>>
>>>> Using the normal Erlang Ports works fine and has no such issues (other
>>>> than the child not coming down with the VM either and no direct kill
>>>> command when the child hangs, which it occasionally does, but os:cmd("kill
>>>> ...") works around that well enough.
>>>>
>>>> Is ErlExec stable enough for high use?  Or am I doing something wrong?
>>>>
>>>
>>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130808/502a9d72/attachment.html>


More information about the erlang-questions mailing list