[erlang-questions] Problem attaching a shell to an Erlang node started through SSH

57 views
Skip to first unread message

André Graf

unread,
Jul 5, 2012, 6:27:56 PM7/5/12
to Erlang Users' List
Hello,

I am working on a small library that uses Python Fabric together with
Rebar deploying of Erlang applications. Fabric provides a scriptable
(it's Python) abstraction over SSH.
While I am able to deploy and upgrade new releases through such a
fabric script I struggle with a simple Erlang node startup.

A fabric call e.g. run("/path/to/my/release/bin/myproject start")
invokes following SSH command
ssh user@remote "/bin/bash -l -c '/path/to/my/release/bin/myproject start'"

This starts the node and I can use the remote shell to operate on the
node. However, attaching a shell to the node triggers a strange
behavior, the shell is available but unusable. It seems the startup
through SSH has somehow confused the involved pipes.

Do you have any hints on that? I am using rebar 2.0.0 R15B
20120625_185716 git 2.0.0-45-gc41fda6.

Cheers,
Andre
_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

Ivan Uemlianin

unread,
Jul 6, 2012, 1:27:25 AM7/6/12
to André Graf, Erlang Users' List
Dear André

This is what we're doing (see my recent email) and the erlang is working fine. I'll be at the office this afternoon to check properly but here are a few differences:

- our fab script uses sudo() instead of run();
- this function calls an unit script instead of calling the release start directly.

> However, attaching a shell to the
> node triggers a strange
behavior, the shell is available but
> unusable. 

What are the symptoms?

Best wishes

Ivan


Sent from my iPhone

André Graf

unread,
Jul 6, 2012, 4:17:47 AM7/6/12
to Ivan Uemlianin, Erlang Users' List
Hi Ivan,

Running EUnit works. I am pretty sure the problem is somehow related
with the runner script generated by Rebar (which I haven't changed).
I tried both sudo and run. I forgot to mention that you must disable
fabric pty when starting the node through the runner script otherwise
the start call succeeds but no node (and also no logs) are generated.

Symptoms are difficult to describe. The resulting shell looks like that:
user@remote:~/test_project/rel/mynode/bin$ sudo ./mynode attach
Attaching to /tmp//home/user/test_project/rel/mynode/erlang.pipe.3 (^D to exit)

^R

So I won't get the normal Erlang shell prompt, I can run some Erlang
commands though, but I don't have any tab-completion.
Ctrl-D will properly exit, Ctrl-G is not giving me the User switch
command, Ctrl-C gives the proper Break menu.

Funny here, If I don't use sudo for the attach I get a "Node is not
running!" although the node was started without using sudo, but this
problem also appears if I start the node directly on the server
without going through SSH.

Cheers,
André

Ivan Uemlianin

unread,
Jul 7, 2012, 6:31:43 AM7/7/12
to André Graf, Erlang Users' List
Dear André

Sorry I made a typo in my email (never try to be helpful before
breakfast;). I should have written:

>> - this function calls an *init* script instead of calling the
>> release start directly.

e.g.:

sudo("webapp start")

Then the shell script "webapp" calls start functions for the python app
and the erlang app (i.e., "/path/to/erlangapp/rel/eappnode/bin/eappnode
start").

> user@remote:~/test_project/rel/mynode/bin$ sudo ./mynode attach
> ...

I didn't know about attach! I've just verified I can ssh onto the
remote machine and attach to the node.

Why is sshing onto the remote machine and attaching better than running
an erlang shell on your local machine and connecting to the remote
machine from there?

Thanks

Ivan
--
============================================================
Ivan A. Uemlianin PhD
Llaisdy
Speech Technology Research and Development

iv...@llaisdy.com
www.llaisdy.com
llaisdy.wordpress.com
github.com/llaisdy
www.linkedin.com/in/ivanuemlianin

"hilaritas excessum habere nequit"
(Spinoza, Ethica, IV, XLII)
============================================================

André Graf

unread,
Jul 7, 2012, 7:38:16 AM7/7/12
to Ivan Uemlianin, Erlang Users' List
Hi Ivan

Thank you for your reply!
Good question, maybe somebody more experienced can shed some light on that one.

Actually the main reason why I stumbled upon these problems is that I
wanted to start the node using the privbind tool for letting a
non-privileged run-user bind to privileged ports such as 80 or 443. If
I used fabric e.g.
sudo('privbind -u myuser /path/to/my/release/bin/myproject start',
pty=False) the fabric call froze my terminal since the privbind
process will terminate after the Erlang node has terminated (hopefully
never). At this point I have two problems: first, why behaves an
attached shell so weird if you start the node through SSH. Second how
to use privbind within a fabric command. For the first one I can well
live with the workaround through the remote shell. For the second
problem I am on the wrong mailing list.

Cheers,
André
Reply all
Reply to author
Forward
0 new messages