歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Erlang---啟動參數學習/研究

Erlang---啟動參數學習/研究

日期:2017/2/28 16:10:33   编辑:Linux教程

erlang啟動參數有3種:emulator flags, flagsplain arguments。

emulator flags 是以“+”開頭的,用來控制模擬器的行為,附送一個非常實用的例子:

相關閱讀:http://www.linuxidc.com/Linux/2011-07/39156.htm

更多關於Erlang的詳細信息,或者下載地址請點這裡

  1. C:\>erl +V
  2. Erlang (SMP,ASYNC_THREADS) (BEAM) emulator version 5.8.2

flags 是以“-”開頭的, 是erlang運行時系統的參數,可以用init:get_argument/1獲得。

plain arguments 普通參數,在第一個flag參數前,或在-- flag之後,-extra後的參數都是普通參數。

  1. </pre><p><span class="bold_code">erl +W w -sname arnie +R 9 -s my_init -extra +bertie</span></p><p><strong></strong> </p><pre class="plain" name="code">% erl +W w -sname arnie +R 9 -s my_init -extra +bertie
  2. (arnie@host)1> init:get_argument(sname).
  3. {ok,[["arnie"]]}
  4. (arnie@host)2> init:get_plain_arguments().
  5. ["+bertie"]

Here +W w and +R 9 are emulator flags. -s my_init is an init flag, interpreted by init. -sname arnie is a user flag, stored by init. It is read by Kernel and will cause the Erlang runtime system to become distributed. Finally, everything after -extra (that is, +bertie) is considered as plain arguments.

Flags

-Application Par Val 把應用中的Par參數設置為值Val;

-args_file FileName 從文件FileName讀取命令行參數;

-boot File 指定啟動使用的boot文件,默認是$ROOT/bin/start.boot,在這個目錄下還有start_clean.boot,start_sasl.boot。如果需要sasl的話,就“-boot start_sasl ”;
-boot_var Var Dir 代替$ROOT用的;

-code_path_cache 不常用;

-compile Mod1 Mod2 ... 不推薦使用了,應該使用erlc;

-config Config 指定配置文件,這個是很有用的,比如在Programming Erlang裡,就用到 erl -boot start_sasl -config elog3,其中文件全名是elog3.config,內容如下:
  1. %% rotating log and minimal tty
  2. [{sasl,[
  3. {sasl_error_logger,false},
  4. %%define the parameters of the rotating log
  5. %%the log file directory
  6. {error_logger_mf_dir,"D:/erlang/otpexample/error_logs"},
  7. %% # bytes per log file
  8. {error_logger_mf_maxbytes,10485760}, %10 MB
  9. %%maximum number of logfiles
  10. {error_logger_mf_maxfiles,10}
  11. ]}].


配置的含義,請參考相關書籍;

-connect_all false 貌似不常用;

-cookie Cookie 被-setcookie代替了;

-detached 脫離console,跑後台erlang進程用的,看做"nohup **** &";

-emu_args debug用的,打印出實際傳給模擬器的值;

-env Variable Value 設置操作系統環境變量用的,比如:

  1. erl -env DISPLAY gin:0

-eval Expr(init flag) 表達式做啟動參數,比如(下列代碼在本機執行出錯,以後再研究):

  1. % erl -eval '{X,Y,Z}' = now(), random:seed(X,Y,Z).'
-extra(init flag) 後面跟的都是普通參數;
-heart 啟動心跳監控器;
-hidden 設置為隱藏節點,該節點會連接集群的所有節點,但是在其他節點執行node/0,不會列出它;
-hosts Hosts erlang運行在那些服務器的IP地址;

-id Id 給erlang進程設置一個id,一般和-sname 和 -name一起用;

-init_debug 在啟動/初始化erlang進程時,打印debug信息;
-instr
-loader Loader 為erl_prim_loader指定裝載模塊的方法,相當於java裡指定classloader;
-make
-man Module
-mode interactive | embedded
-name Name 給一個erlang節點/進程設置一個名稱
-noinput
-noshell
-nostick

-pa Dir1 Dir2 ...

-pz Dir1 Dir2 ...
-remsh Node 遠程啟動一個erlang節點,比如(當然RSA神馬的,要先搞定):
  1. erl -sname node1 -remsh [email protected]
-rsh Program 遠程啟動一個slave erlang節點,這裡 http://www.linuxidc.com/Linux/2011-07/39157p3.htm 有一個例子;
-run Mod [Func [Arg1, Arg2, ...]]
-s Mod [Func [Arg1, Arg2, ...]]
-setcookie Cookie 給節點設置cookie,比如:
  1. erl -setcookie SFEWRG34AFDSGAFG35235 -name nodex

並且它是運行時可以改的:

  1. erlang:set_cookie(node(), 'SFEWRG34AFDSGAFG35235').


-shutdown_time Time 關閉節點需要的時間,如果超過,就直接kill,默認是infinity

-sname Name 給節點設置名字,和-name類似,不過它的結果是:Name@Host ;
-smp [enable|auto|disable] 是否需要支持smp,默認應該是enable的,smp的好處見這裡 http://www.linuxidc.com/Linux/2011-07/39157p2.htm
-version(emulator flag)

Emulator Flags

+a size 一般實用默認值就可以了。

Suggested stack size, in kilowords, for threads in the async-thread pool. Valid range is 16-8192 kilowords. The default suggested stack size is 16 kilowords, i.e, 64 kilobyte on 32-bit architectures. This small default size has been chosen since the amount of async-threads might be quite large. The default size is enough for drivers delivered with Erlang/OTP, but might not be sufficiently large for other dynamically linked in drivers that use the driver_async() functionality. Note that the value passed is only a suggestion, and it might even be ignored on some platforms.

+A size 一步線程池的大小,默認是0;比如執行werl +A 1,會看到:

  1. Erlang R14B01 (erts-5.8.2) [smp:2:2] [rq:2] [async-threads:1]
  2. Eshell V5.8.2 (abort with ^G)


+B [c | d | i]

+c

+d 默認情況下erlang進程遇到內部錯誤,比如oom,會產生一個crash dump和core dump,+d讓節點只產生後者;

+e Number ETS表的最大數量;
+ec強制ETS表啟動壓縮,一般不用的;
+fnl 如果文件名使用了ISO-latin-1編碼;
+fnu如果文件名使用了UTF-8 編碼;

+fna 和當前操作系統一致;

+hms Size 指定erlang進程的默認(最小?)堆內存大小(這個應該不用太擔心);
+hmbs Size 進程默認二進制虛擬內存堆大小;
+K true | false 是否開啟kernel poll,就是epoll;
+l
+MFlag Value

+P Number erlang節點系統的最大並發進程數;

+R ReleaseNumber

+r

+rg ReaderGroupsLimit Limits the amount of reader groups used by read/write locks optimized for read operations in the Erlang runtime system. By default the reader groups limit equals 8.

+S Schedulers:SchedulerOnline
+sFlag Value

+t size

+T Level

+V 模擬器版本號

+v verbose

+W w | i

+zFlag Value

Environment variables

ERL_CRASH_DUMP

ERL_CRASH_DUMP_NICE

ERL_CRASH_DUMP_SECONDS

ERL_AFLAGS

ERL_ZFLAGS 和 ERL_FLAGS

ERL_LIBS

ERL_EPMD_PORT
Copyright © Linux教程網 All Rights Reserved