[Erlang危機](4.4)具名管道,erlang4.4
原創文章,轉載請註明出處:伺服器非業餘研究http://blog.csdn.net/erlib 作者Sunface聯絡郵箱:cto@188.com
Named Pipes具名管道(Named Pipes)
A little known way to connect with an Erlang node that requires no explicit distribution is through named pipes. This can be done by starting Erlang with run_erl, which wraps Erlang in a named pipe 5:
還有一種鮮為人知串連Erlang節點的方法:具名管道(named pipes),可以通過使用run_erl 啟動Erlang來完成 (Erlang會被包裹在具名管道內)5。
-------------------------------------------------------------------------------------
$ run_erl /tmp/erl_pipe /tmp/log_dir "erl"
-------------------------------------------------------------------------------------
The first argument is the name of the file that will act as the named pipe. The second one is where logs will be saved 6.
第一個參數是指定作為具名管道的檔案,第二個是存放日誌的目錄6。
To connect to the node, you use the to_erl program:
你可以使用 to_erl程式串連到節點上:
-------------------------------------------------------------------------------------
$ to_erl /tmp/erl_pipe
Attaching to /tmp/erl_pipe (^D to exit)
1>
-------------------------------------------------------------------------------------
And the shell is connected. Closing stdio (with ˆD) will disconnect from the shell while leaving it running.
串連上後,你可以使用ctrl+D來斷開遠程節點(只是斷開,不會終結遠程節點).
[5] "erl" is the command being run. Additional arguments can be added after it. For example "erl +K true" will turn kernel polling on.
[6] Using this method ends up calling fsync for each piece of output, which may give quite a performance hit if a lot of IO is taking place over standard output.
[注5]:“erl”就是要啟動並執行命令,你也可以在後面加上其它啟動選項如"erl +K ture"會把開啟核心kernel輪詢。
[注6] :這個方法最終會調用fsync會同步每一塊輸出,如果有大量的IO操作產生,效能會下降得很厲害。