erlang

How to get elixir nodes to connect automatically on startup?

廉价感情. 提交于 2019-12-22 18:43:29
问题 Background I'm trying to setup clustering between a few elixir nodes. My understanding is that I can set this up by modifying the release vm.args. I'm using Distillery to build releases and am following the documentation here: https://hexdocs.pm/distillery/config/runtime.html. My rel/vm.args file is as follows: -name <%= release_name %>@${HOSTNAME} -setcookie <%= release.profile.cookie %> -smp auto -kernel inet_dist_listen_min 9100 inet_dist_listen_max 9155 -kernel sync_nodes_mandatory '[$

erlang zip:unzip/1 {error, bad_central_directory} and {error, bad_eocd}

风流意气都作罢 提交于 2019-12-22 18:19:54
问题 I have always used erlang stdlib library zip:unzip/1 successfully. Last night i hit a bar with this error: E:\WimaxStatsParser-1.1>erl Eshell V5.9.2 (abort with ^G) 1> zip:unzip("e:/WimaxStatsParser-1.1/in/SomeZipFile.zip"). {error,bad_central_directory} 2> Some one help explain the cause for this ? and how i get around it ? ADDITIONS I got some other error on another file: {error,bad_eocd} . Please explain this as well. 回答1: I am not able to reproduce your problem with the information you

extending ejabberd with modules for custom mysql schema?

天涯浪子 提交于 2019-12-22 17:59:08
问题 Instead of ejabberd.sql,I am using a custom MySQL schema(because of legacy reasons). I will be doing some DB operations on certain activities like Ping,Pong,Msg deliverd,Msg read and most importantly getting/setting roster list and announcing presence(all of these on my own schema). However,ejabberd seems to use ejabberd.sql all throughout and its source code is pretty much dependent on it.Fiddling with the source code is the last thing I would do since I am not aware of its dependencies.

001-rabbitmq和haproxy结合

梦想的初衷 提交于 2019-12-22 14:06:46
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> rabbitmq集群搭建 防火墙添加并重启 -A INPUT -p tcp -m multiport --dports 4369,25672,5672,15672 -j ACCEPT 安装 cd /usr/local/src/; wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.16/rabbitmq-server-3.7.16-1.el7.noarch.rpm curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash yum install erlang -y yum install rabbitmq-server-3.7.16-1.el7.noarch.rpm -y 四台服务器的/etc/hosts配置统一 192.168.1.1 node1 192.168.1.1 node2 192.168.1.1 node3 192.168.1.1 node4 确认每一台的.erlang.cookie的配置统一 chmod 700 /var/lib/rabbitmq/.erlang.cookie

Should I use try catch in Erlang or should I pass back an error token?

送分小仙女□ 提交于 2019-12-22 10:15:32
问题 I'm coding in Erlang and a I am bit unsure about how to approach error handling, especially after seeing the ugly errors Erlang always returns. Should I use try catch in Erlang or should I pass back an error token? 回答1: There are three basic ways to do exception handling in sequential Erlang: throws ( throw(Term) ) errors ( erlang:error(Reason) ) exits ( exit(Reason) ) Throws are to be used for non-local returns and some kinds of exception you expect to be able to handle (maybe because they

Erlang: Mnesia can not create schema while release with rebar

笑着哭i 提交于 2019-12-22 10:12:08
问题 When I call mnesia:create_schema on startup, the program crashes. If I run my program in ebin without releasing it, it works find. The error log as follows: =INFO REPORT==== 3-Jul-2013::09:44:06 === application: eddy exited: {bad_return, {{eddy_app,start,[normal,[]]}, {'EXIT', {{badmatch, {error, {'EXIT', {undef, [{mnesia_backup,open_write, ["/home/cometeor/eddy/rel/eddy/Mnesia.eddy@127.0.0.1/eddy@127.0.0.1137284464686415846847780"], []}, {mnesia_bup,do_apply,4, [{file,"mnesia_bup.erl"},{line

Erlang: How to include libraries

℡╲_俬逩灬. 提交于 2019-12-22 10:04:08
问题 I'm writing a simple Erlang program that requests an URL and parses the response as JSON. To do that, I need to use a Library called Jiffy. I downloaded and compiled it, and now i have a .beam file along with a .app file. My question is: How do I use it? How do I include this library in my program?. I cannot understand why I can't find an answer on the web for something that must be very crucial. Erlang has an include syntax, but receives a .hrl file. Thanks! 回答1: You don't need to include

How to check whether input is a string in Erlang?

淺唱寂寞╮ 提交于 2019-12-22 09:37:11
问题 I would like to write a function to check if the input is a string or not like this: is_string(Input) -> case check_if_string(Input) of true -> {ok, Input}; false -> error end. But I found it is tricky to check whether the input is a string in Erlang. The string definition in Erlang is here: http://erlang.org/doc/man/string.html. Any suggestions? Thanks in advance. 回答1: In Erlang a string can be actually quite a few things, so there are a few ways to do this depending on exactly what you mean

list convert to pid function list_to_pid/1 restriction

笑着哭i 提交于 2019-12-22 09:06:00
问题 When test open source project 'gproc' function, I found list_to_pid is ok for local pid, and not ok for remote pid. My erlang runtime is R15B. (dist_test_n2@yus-iMac.local)29> D = list_to_pid("<0.239.0>"). <0.239.0> (dist_test_n2@yus-iMac.local)30> D == self(). %% equal here true (dist_test_n2@yus-iMac.local)31> f(E). ok (dist_test_n2@yus-iMac.local)32> E = gproc:where(Name). <8969.239.0> (dist_test_n2@yus-iMac.local)33> F = list_to_pid("<8969.239.0>"). <8969.239.0> (dist_test_n2@yus-iMac

In Erlang how to get Client's ip and port?

不想你离开。 提交于 2019-12-22 08:46:50
问题 In the following code , server is listening to port 2345. After accepting connection from client it returns {ok, Socket} start() -> {ok, Listen} = gen_tcp:listen(2345, [binary, {packet, 4}, {reuseaddr, true}, {active, true}]), {ok, Socket} = gen_tcp:accept(Listen). I want to get client's IP and port, how can I get them by analyzing socket? 回答1: Use inet:peername/1 . The description of the function from documentation: peername(Socket) -> {ok, {Address, Port}} | {error, posix()} Types: Socket =