Erlang---启动参数学习/研究
Erlang---启动参数学习/研究
erlang启动参数有3种:emulator flags, flags 和plain arguments。
emulator flags 是以“+”开头的,用来控制模拟器的行为,附送一个非常实用的例子:
相关阅读:
更多关于Erlang的详细信息,或者下载地址请点这里
- C:\>erl +V
- Erlang (SMP,ASYNC_THREADS) (BEAM) emulator version 5.8.2
flags 是以“-”开头的, 是erlang运行时系统的参数,可以用init:get_argument/1获得。
plain arguments 普通参数,在第一个flag参数前,或在-- flag之后,-extra后的参数都是普通参数。
- </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
- (arnie@host)1> init:get_argument(sname).
- {ok,[["arnie"]]}
- (arnie@host)2> init:get_plain_arguments().
- ["+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读取命令行参数;
-code_path_cache 不常用;
-compile Mod1 Mod2 ... 不推荐使用了,应该使用erlc;
- %% rotating log and minimal tty
- [{sasl,[
- {sasl_error_logger,false},
- %%define the parameters of the rotating log
- %%the log file directory
- {error_logger_mf_dir,"D:/erlang/otpexample/error_logs"},
- %% # bytes per log file
- {error_logger_mf_maxbytes,10485760}, %10 MB
- %%maximum number of logfiles
- {error_logger_mf_maxfiles,10}
- ]}].
配置的含义,请参考相关书籍;
-cookie Cookie 被-setcookie代替了;
-detached 脱离console,跑后台erlang进程用的,看做"nohup **** &";
-emu_args debug用的,打印出实际传给模拟器的值;
-env Variable Value 设置操作系统环境变量用的,比如:
- erl -env DISPLAY gin:0
-eval Expr(init flag) 表达式做启动参数,比如(下列代码在本机执行出错,以后再研究):
- % erl -eval '{X,Y,Z}' = now(), random:seed(X,Y,Z).'
-id Id 给erlang进程设置一个id,一般和-sname 和 -name一起用;
-pa Dir1 Dir2 ...
- erl -sname node1 -remsh node2@machine2.example.com
- erl -setcookie SFEWRG34AFDSGAFG35235 -name nodex
并且它是运行时可以改的:
- erlang:set_cookie(node(), 'SFEWRG34AFDSGAFG35235').
-shutdown_time Time 关闭节点需要的时间,如果超过,就直接kill,默认是infinity;
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,会看到:
- Erlang R14B01 (erts-5.8.2) [smp:2:2] [rq:2] [async-threads:1]
- Eshell V5.8.2 (abort with ^G)
+B [c | d | i]
+d 默认情况下erlang进程遇到内部错误,比如oom,会产生一个crash dump和core dump,+d让节点只产生后者;
+fna 和当前操作系统一致;
+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 模拟器版本号
+W w | i
Environment variables
ERL_CRASH_DUMP
ERL_CRASH_DUMP_NICE
ERL_CRASH_DUMP_SECONDS
ERL_AFLAGS
ERL_ZFLAGS 和 ERL_FLAGS
ERL_LIBS
|
评论暂时关闭