[erlang-questions] Erlang newbie questions
Mon Oct 24 02:57:23 CEST 2011
Hi Garrett & all,
About this part:
> I use run_erl to run Erlang. This doesn't plug into typical watchdog
> apps, which look for pids, but it provides a way to communicate with
> Erlang (using to_erl) without using distributed Erlang. I've used this
> technique extensively and find it robust.
I've also used run_erl and found it less than robust. I'd like to
highlight the following issues:
* You can specify the pipe directory but not the pipe names. This
means that if you want to run two or more emulators, you cannot tie
the pipe name (which you need in order to connect to the VM) to the
emulator. (You can give every one a different directory if you
re-write the start script but this seems like a workaround rather than
a proper feature and the next issue still causes problems...)
* The pipes aren't cleaned up if the emulator crashes or won't start.
Even if you run only a single emulator, it may be running on
/tmp/erlang.pipe.1 or /tmp/erlang.pipe.2 or whatever, depending on
* run_erl provides only a single connection. If a program or user
already has the pipe open, other connects will hang or fail. A locked
up session will therefore prevent you from establishing another
session to clean it up -- or to shut down the emulator.
* run_erl's single session is like a shared terminal: it has a shared
input buffer and the state isn't reset or cleared between connections.
If you set up a script or program to use it to control an emulator,
what happens if someone's session (or a bug in a program) leaves an
unfinished command or term in the buffer? (What happens is that all
subsequent commands fail, that's what!)
* Be careful using run_erl without specifying which pipe to use. It's
default is to try each in turn until it gets a connect.
It's easy to see these problems in action. On Ubuntu (and probably on
a stock compile as well) try running "/usr/lib/erlang/bin/start" on
the command line. Here's what happens on my system for a really
$ echo $?
So it has started successfully! Yay!
No running Erlang on pipe /tmp/erlang.pipe.2: No such device or address
Why isn't it running? Why is it erlang.pipe.2 instead of .1?
Where are the logs? Nowhere?
Of course through experience I know what kind of problems will be
happening here but good luck figuring it out if you're new to Erlang.
For fun try setting up an init script that uses to_erl to control an
emulator. Then do this:
echo x > /tmp/erlang.pipe.1.w
And then try to use your script.
P.S. I still love Erlang. I'm just sayin' it "for the record" as Joe suggests.
More information about the erlang-questions