erlang

【原创】Erlang 之 erl_crash.dump 文件分析

为君一笑 提交于 2019-12-10 07:45:23
前一篇博文 中描述了 erl_crash.dump 文件的生成,本文主要讲解如何针对 erl_crash.dump 文件进行分析。 -=-=-=- 我是88界奥斯卡颁奖礼的分隔线 -=-=-=- 首先看一下坚强兄的博文《 [Erlang 0057] Erlang 排错利器: Erlang Crash Dump Viewer 》中的内容: 1. 基于 crashdump_viewer 的 web 页面进行 erl_crash.dump 分析; crashdump_viewer:start(). 补充: The Crashdump Viewer is an HTML based tool for browsing Erlang crashdumps. Crashdump Viewer runs under the WebTool application. 2. 基于 recon 的 erl_crashdump_analyzer.sh 分析脚本 进行 erl_crash.dump 分析; -=-=-=- 我是88界奥斯卡颁奖礼的分隔线 -=-=-=- 文章中涉及两种工具,下面分别说明; 【crashdump_viewer】 【 erl_crashdump_analyzer.sh 】 该脚本是 recon 工具套装中的一个,详情可以参考 github 上的说明 ; 下面针对 erl

【原创】Erlang 之 erl_crash.dump 文件生成

坚强是说给别人听的谎言 提交于 2019-12-10 07:07:08
本文内容针对霸爷的博客《 产生crashdump的三种方法 》进行实验验证和总结。 -=-=-=-=- 我是<我是歌手 >的分隔线 -=-=-=-=- (以下为原文引用) crashdump 对于 erlang 的系统来讲如同 core 对于 c/c++ 程序一样宝贵,对于系统问题的修复提供了最详细的资料。当然 erlang 很贴心了提供了网页版的 crashdump_view 帮助用户解读数据,使用方法如下: crashdump_viewer:start(). 因为 crashdump 文本文件里面记录了大量系统相关的信息,这些信息对于分析系统的性能,状态,排除问题提供了不可替代的功能。所以很需要在系统正常运作的时候,得到 crashdump 文件。 除了坐等系统在发生问题时,自动产生 crashdump 以外,另外还有三种方法来手动产生 crashdump 。 方法如下: erlang:halt("abort"). 在 erlang shell 下输入 Ctrl+c + “大写的A” kill -s SIGUSR1 [erlang_pid] -=-=-=-=- 我是<我是歌手 >的分隔线 -=-=-=-=- (以下为实际验证) 【实验一】 某业务进程运行中 [root@Betty upu]# ps aux|grep upu root 2185 0.0 0.0 12908 796

Must UTF-8 binaries include /utf8 in the binary literal in Erlang?

我的未来我决定 提交于 2019-12-10 04:30:23
问题 In erlang, when defining a UTF-8 binary string, I need to specify the encoding in the binary literal, like this: Star = <<"★"/utf8>>. > <<226,152,133>> io:format("~ts~n", [Star]). > ★ > ok But, if the /utf8 encoding is omitted, the unicode characters are not handled correctly: Star1 = <<"★">>. > <<5>> io:format("~ts~n", [Star1]). > ^E > ok Is there a way that I can create literal binary strings like this without having to specify /utf8 in every binary I create? My code has quite a few

Node.Js in Erlang style?

邮差的信 提交于 2019-12-10 04:28:44
问题 I am a complete noob when it comes to both Node.Js and Erlang. But wouldn't it be possible to build a Node.js app that emulates Erlang behavior? e.g. you pass json messages across an distributed node.js server park and even pass new code to those servers w/o going offline, just like erlang. If you have a message handler callback that is activated when a message is received, then this message handler could check if the message is a code update message and thus replace itself(the current

Erlang: Is there a way to reload changed modules into an already running node with rebar?

雨燕双飞 提交于 2019-12-10 04:22:59
问题 The rebar build tool seems pretty cool, but is there a way to recompile AND reload files into a currently running node with it? 回答1: I don't see a need to bring rebar into it. I use reloader.erl from the Mochiweb project. Just build this module along with the rest of your program and call reloader:start() early in your app's initialization sequence. After that call, any time a module in your program changes on disk, the reloader will replace the running copy automatically. 来源: https:/

erlang程序运行的几种方式

亡梦爱人 提交于 2019-12-10 03:04:14
1.在erlang shell中编译运行 -module(hello). -export([start/0]). start() -> io:format("Hello world~n"). erl Erlang R14B03 (erts-5.8.4) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.8.4 (abortwith ^G) 1> c(hello). {ok,hello} 2> hello: module_info/0 module_info/1 start/0 2> hello:start(). Hello world ok 3>   2 在命令行提示符下编译运行 erlc hello.erl erl -noshell -s hello start -s init stop 快速脚本 erl -eval 'io:format("Memory:~p~n",[erlang:memory(total)]).' -noshell -s init stop 3 当做escript脚本运行 #!/usr/bin/escript main(_) -> io:format("Hello World~n"). chmod +x hello ./hello 来源:

5.编译并运行erlang程序

て烟熏妆下的殇ゞ 提交于 2019-12-10 02:49:11
1.停止erlang系统方法: ctrl+C(Windows下 ctrl+Break). 不可控关闭BIF函数: erlang:halt() 强制停止系统(小瑕疵:对于大型的数据库操作程序,可能在下次需要进行一些回复操作) 可控关闭:q().该函数是init:stop()在shell中的简写,该操作会做一些清除和关闭操作,保证系统正确关闭 2.为文件加载器设定加载路径 code:get_path(). 获得当前设定的文件加载路径列表 @spec code:add_patha(Dir) 增加新目录到当前加载路径列表的开头 @spec code:add_patha(Dir) 增加新目录到当前加载路径列表的末尾 @spec code:all_loaded() 返回所有加载的模块,有利于确定那些模块加载出错 @spec code:clash() 分析加载目录是否有重复模块 注:code模块有些函数可以用来分析加载路径 init:get_argument(home) 获得erlang系统所需的home目录 3. erlang程序运行方式 erlang代码如下 -module(hello). -export([start/0]). start() -> io:format("Hello world~n"). (1). shell中编译运行: c(hello). hello:start().

Translate CouchDB javascript views to erlang

最后都变了- 提交于 2019-12-10 02:43:38
问题 I need some help with translating the following CouchDB views from javascript to erlang. I need them in erlang, because in javascript the view uses all of the available stack memory and crashes couchjs (see this bugreport https://issues.apache.org/jira/browse/COUCHDB-893). The current map functions I have in javascript are: sync/transaction_keys function(doc) { if(doc.doc_type == "Device") { for(key in doc.transactions) emit(key, null); } } and sync/transcation function(doc) { if(doc.doc_type

How to convert datetime() to timestamp() in erlang

大憨熊 提交于 2019-12-10 02:04:11
问题 I need to convert {{2012, 9, 21}, {13, 21, 11}} into timestamp(). How can I do that? Thank you. 回答1: Corrected version: Seconds = calendar:datetime_to_gregorian_seconds(DateTime) - 62167219200, %% 62167219200 == calendar:datetime_to_gregorian_seconds({{1970, 1, 1}, {0, 0, 0}}) {Seconds div 1000000, Seconds rem 1000000, 0}. 回答2: You might use this to_timestamp({{Year,Month,Day},{Hours,Minutes,Seconds}}) -> (calendar:datetime_to_gregorian_seconds( {{Year,Month,Day},{Hours,Minutes,Seconds}} ) -

Command 'generate' not understood or not applicable

三世轮回 提交于 2019-12-10 01:52:19
问题 I am trying to run rebar generate to generate a release for an erlang rebar project and getting the following error. Any ideas what I am doing wrong? ./rebar generate Command 'generate' not understood or not applicable I am on OSX with erlang version Erlang R14B03 and below is my rebar.conf {lib_dirs, ["deps"]}. {sub_dirs, ["rel"]}. {deps, [ {folsom, ".*", {git, "git://github.com/boundary/folsom", "master"}} ]}. {require_otp_vsn, "R14|R15"}. {erl_opts, [ fail_on_warning, debug_info, warn