erlang

Escript: setting code path relative to script directory

本小妞迷上赌 提交于 2020-01-23 05:54:28
问题 When I try to set a relative code path in a escript with -pz like this #!/usr/bin/env escript %% -*- erlang -*- %%! -pz ../dir-of-some-beams The path is interpreted relative to the directory from where I run the escript from, which renders it useless for setting the path relative to the script location. My current "workaround" is using a absolute path which is annoying since all this is part of a repository and I don't want it to be location dependent. So how can I set the code path relative

Escript: setting code path relative to script directory

荒凉一梦 提交于 2020-01-23 05:53:11
问题 When I try to set a relative code path in a escript with -pz like this #!/usr/bin/env escript %% -*- erlang -*- %%! -pz ../dir-of-some-beams The path is interpreted relative to the directory from where I run the escript from, which renders it useless for setting the path relative to the script location. My current "workaround" is using a absolute path which is annoying since all this is part of a repository and I don't want it to be location dependent. So how can I set the code path relative

undefined function maps:to_json/1

 ̄綄美尐妖づ 提交于 2020-01-23 05:12:45
问题 This is one of the things I learned from Programming Erlang, 2nd Ed , but doesn't seem to work on shell $ erl Erlang/OTP 17 [erts-6.2] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace] Eshell V6.2 (abort with ^G) 1> Dic = #{b => 1, a => 2}. #{a => 2,b => 1} 2> maps:to_json(Dic). ** exception error: undefined function maps:to_json/1 3> What's wrong here? 回答1: Programming Erlang, 2nd Ed was written before maps were introduced in release 17 (as experimental

Erlang Supervisor Strategy For Restarting Connections to Downed Hosts

一笑奈何 提交于 2020-01-22 19:48:26
问题 I'm using erlang as a bridge between services and I was wondering what advice people had for handling downed connections? I'm taking input from local files and piping them out to AMQP and it's conceivable that the AMQP broker could go down. For that case I would want to keep retrying to connect to the AMQP server but I don't want to peg the CPU with those connections attempts. My inclination is to put a sleep into the reboot of the AMQP code. Wouldn't that 'hack' essentially circumvent the

What could cause the `net_adm` kernel Erlang module to be unavailable?

百般思念 提交于 2020-01-21 19:18:30
问题 Installed Erlang (releases from 19 to 22) using the Nix package manager apt and compiling from source on Ubuntu 18.04 with Xmonad and Debian 9 running in the cloud , but every time, net_adm is not available through the Erlang shell event though other kernel modules are. I assume that this is caused by an external system configuration because couldn't find anything about this online, so people are not complaining about it. (Only found one person so far.) 回答1: Kind of ashamed to admit that I am

VM安装centos7

∥☆過路亽.° 提交于 2020-01-21 15:04:41
RabbitMQ:   RabbitMQ是流行的开源消息队列系统,是AMQP(Advanced Message Queuing Protocol高级消息队列协议)的标准实现,用erlang语言开发。RabbitMQ据说具有良好的性能和时效性,同时还能够非常好的支持集群和负载部署,非常适合在较大规模的分布式系统中使用。          注意:关于centos上安装rabbitmq会有很大问题,大家可以参考我这篇博客,已经可以正常访问。(网上有很多安装都是有问题的,大家可以自己试一下) RabbitMQ安装步骤:   准备工作:     1> vm安装centos: VM安装centos7     2>安装ifconfig,lrzsz,更新yum源等操作。参考: https://www.cnblogs.com/huhongy/p/7766107.html   1> 由于rabbitMQ安装的依赖于erlang,所以需要先进行安装前提环境:     yum install gcc glibc-devel make ncurses-devel openssl-devel xmlto   2> 下载epel-release:     在官网上下载 epel-release 网址http://rpm.pbone.net/index.php3/stat/4/idpl/29069710/dir

erlang 内部监控工具的方法

放肆的年华 提交于 2020-01-21 07:04:15
系统级别perf top, dstat -tam, vtune 都能很好分析beam 瓶颈,本文主要erlang 级别排查: 1. 反编译 确认线上运行代码是否正确,reltools没掌握好,升级偶尔出现问题 decompile(Mod) -> {ok,{_,[{abstract_code,{_,AC}}]}} = beam_lib:chunks(code:which(Mod), [abstract_code]), io:format("~s~n", [erl_prettypr:format(erl_syntax:form_list(AC))]). 2. 进程栈 类似于jstack,发现大量进程挂起,进程数过高,运行慢,hang住等问题用到 pstack(Reg) when is_atom(Reg) -> case whereis(Reg) of undefined -> undefined; Pid -> pstack(Pid) end; pstack(Pid) -> io:format("~s~n", [element(2, process_info(Pid, backtrace))]). 3. etop 分析内存、cpu占用进程,即使数十w进程node 也能正常使用 %进程CPU占用排名 etop() -> spawn(fun() -> etop:start([{output

CouchBase 1.8 and 2.0 Erlang SDKs? Why is Erlang Left out

戏子无情 提交于 2020-01-21 04:48:05
问题 I really enjoy seeing the great work being done by CouchBase team on providing us with a great NoSQL solution. However, despite the fact that there are few erlang Web developers compared to perhaps ruby, PHP, java or Python, the number of developers picking up erlang are increasing. Which brings me to why on their SDK page, they have constantly left out Erlang. With yaws web Server, Mochiweb, and many other Erlang Web libraries, why in the world would they not support Erlang in their NoSQL

rabbitmq主备模式部署

醉酒当歌 提交于 2020-01-20 22:37:26
192.168.15.240 主机名rabbitmq240 192.168.15.241 主机名rabbitmq241 vip: 192.168.15.1 vip: 192.168.15.2 1.两台机器安装 yum -y install erlang.x86_64 ln -s /usr/local/erlang/bin/erl /usr/bin/erl ln -s /usr/local/erlang/bin/epmd /usr/bin/epmd yum -y install rabbitmq.x86_64 2.配置主机名, echo "192.168.15.240 rabbitmq240" >> /etc/hosts echo "192.168.15.241 rabbitmq241" >> /etc/hosts 3.master 192.168.15.240操作 /usr/local/rabbitmq/sbin/rabbitmq-server -detached 生成文件:~/.erlang.cookie cat ~/.erlang.cookie 在master上启动代理:python -m SimpleHTTPServer 7890,备机上执行:wget http://192.168.15.240:7890/.erlang.cookie获取文件

RabbitMQ的安装及使用

一曲冷凌霜 提交于 2020-01-20 18:13:33
rabbitmq作为使用最广泛之一的消息中间件,它采用了erlang语音编写,它支持多种客户端的使用,其采用的基础协议是AMQP 0.9.1,其特点是高可用、高可靠、多语言客户端支持、灵活的路由功能、具有插件机制如Federation插件、具有管理界面、消息可跟踪、支持多种协议如AMQP 0-9-1, AMQP 1.0, MQTT及STOMP、支持消息集群,多语言客户端支持可查看官网 https://www.rabbitmq.com/getstarted.html 。 我们看下它在centos7上的安装,因为它是由erlang语音开发的,因此我们必须要有erlang语音环境,在官网上介绍有下面几种获取方式: A.是rabbitmq团队提供的专门精简化后用于支持rabbitmq的版本。 B.Erlang解决方案给出的包通常是合理并且也是最新版本,但是可能安装过多的依赖项列表。 C.EPEL-企业Linux的额外软件包,它是由Red Hat/Fedora 组织提供的额外的对应官方包,但是就是可能不是最新的安装包。 D.openSUSE为每个发行版生成Erlang包(openSUSE和SLES)。 我们的安装还是使用了Erlang解决方案给出的最新包,获取如下: 1.获取erlang解决方案 wget https://packages.erlang-solutions.com