touch erlang (by quqi99)

作者:张华 发表于:2020-02-25
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明

hello world

  • erlang里的模块类似于类,进程则类似于类实例(相当于携程但通过消息通讯)
  • erlang变量以大写字母开头,以小写字母开头的则是符号常量,也称为原子(atom)
  • module为载模块,’-module(hello). '应与文件名hello.erl同名 每行以.结束
  • export向外暴露函数为public,默认为private, start/0中的0代表参数个数
cat << EOF | sudo tee hello.erl
%% coding: utf-8
-module(hello).  
-export([start/0]).  
start() ->   
    io:format("hello~n"). 
EOF
hua@t440p:/tmp$ erl
1> c(hello).
{ok,hello}
2> hello:start().
hello
ok
3> halt().
erlc hello.erl
hua@t440p:/tmp$ ls
hello.beam  hello.erl
erl -noshell -s hello start -s init stop  #first load hello:start(), then load hello:stop()

create erlang database - Mnesia

hua@t440p:/tmp$ erl
1> mnesia:create_schema([node()]).
ok
2> init:stop().
ok
3> hua@t440p:/tmp$ ls
hello.beam  hello.erl  Mnesia.nonode@nohost

OTP (Open Telecom Platform)

OTP-开放电信平台,名字有些误导性,因为OTP实际要通用的多, 它是一个应用程序操作系统,包含了一组库和实现(如一个web server, ftp server, corba orb etc),可以构建大规模,容错和分布式的应用程序.OTP行为可以看作是一个用回调函数作为参数的应用程序框架.

erlang core dump

一般说来抓dump 4种 方式:

  • erlang:halt(“abort”).
  • 在erlang shell下输入CTRL C + “大写的A”
  • 等着进程崩溃自己产生dump 4, kill -SIGUSR1 (shell 无法进入时可以使用)例如已经产生了erl_crash.dump(ulimit -c unlimited设置之后运行beam出错时就会自动产生)
echo "deb http://ddebs.ubuntu.com $(lsb_release -cs) main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ddebs.list
sudo apt update
sudo apt-cache search erlang |grep dbgsym
sudo apt install erlang-base-dbgsym -y
#source code must be the same version (erlang9.2 is using tag 20.2.2 according to 'sudo apt-get source erlang')
git clone https://github.com/erlang/otp.git
git checkout -b OTP-20.2.2
gdb /usr/lib/erlang/erts-9.2/bin/beam.smp ./core.dump -d /bak/linux/otp/erts/emulator
#https://www.erlang-solutions.com/blog/how-to-analyse-a-beam-core-dump.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

quqi99

你的鼓励就是我创造的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值