erlang

Erlang ports and thread safety

99封情书 提交于 2019-12-12 19:11:18
问题 I'm looking to call a C function from an Erlang process via an Erlang port, as described here: http://www.erlang.org/doc/tutorial/c_port.html In production I will need multiple Erlang processes calling the C function in parallel, each with a different set of arguments. My question is, will this be thread safe at the C function level ? The docs talk about the controlling Erlang process creating a 'connected process', which it sounds as if is responsible for creating an isolated instance of the

How to keep track of a process per browser window and access it at each event in Nitrogen?

本秂侑毒 提交于 2019-12-12 18:19:28
问题 In Nitrogen, the Erlang web framework, I have the following problem. I have a process that takes care of sending and receiving messages to another process that acts as a hub. This process acts as the comet process to receive the messages and update the page. The problem is that when the user process a button I get a call to event. How do I get ahold of that Pid at an event. the code that initiates the communication and sets up the receiving part looks like this, first I have an event which

ejabberd: is there a way to configure a different “cookie” than “ejabberd”?

谁都会走 提交于 2019-12-12 18:00:56
问题 I am building an ejabberd module. I require this module to perform RPC calls to another node on the same LAN (sname). From what I understand, ejabberd configures it owns "cookie" which, of course, will differ from the cookie I use for my other nodes. Is there a way to force ejabberd to use another cookie? EDIT: ejabberd starts its daemon under the "ejabberd" username. EDIT: even when creating /home/ejabberd/.erlang.cookie (username: ejabberd, group: ejabberd) with an appropriate cookie it

How does the recursive call work in this erlang function?

谁都会走 提交于 2019-12-12 17:43:41
问题 fun({0, M}) -> {M+1, M-2}; fun({N, M}) -> {A, B} = fun({N-1, M+1}), {B, A+1}. so I am kinda unsure of what the A and B would be and how the next recursive call would be. let say 2,2 so it would be f(2,2) -> {A,B} = fun({1,3}), {B,A+1} f(1,3) -> {A,B} = fun({0,4}), {B,A+1} f(0,4) -> {5,2} but where does A and B go and do they change in each recursive call? 回答1: As a very basic explanation of "where is my variable", consider the countdown function in this example module: -module(example).

ejabberd supervisor module

家住魔仙堡 提交于 2019-12-12 17:23:00
问题 I need to keep a gen_mod process running as it loops every minute and does some cleanup. However once every few days it will crash and I'll have to manually start it back up again. I could use a basic example of implementing a supervisor into ejabberd_sup so it can keep going. I am struggling to understand the examples that use gen_server. Thanks for the help. 回答1: Here's an example module combining ejabberd's gen_mod and OTP's gen_server . Explanation is inlined in the code. -module(cleaner)

离线解决Rabbitmq启动报“line 80: erl: command not found”

六眼飞鱼酱① 提交于 2019-12-12 17:19:08
问题描述: 部署一套新环境,因为该环境的机器规定不能连外网,rabbitmq采用离线部署的方式。 将本地yum下载的rabbitmq所需rpm包手动上传到该环境的机器离线部署。所有的rpm包都和本地在线安装都是一样的,本地测试机上部署和启动正常,但是在新环境机器上启动rabbitmq的时候出现了“/usr/lib/rabbitmq/bin/rabbitmq-server: line 80: erl: command not found”的报错。报错信息如下: [root@host1 ~]# rabbitmq-server /usr/lib/rabbitmq/bin/rabbitmq-server: line 80: erl: command not found [root@host1 ~]# 分析过程: 1、根据报错说“erl: command not found”,就单独执行了一下erl,发现并没有什么问题: [root@host1 ~]# erl Erlang/OTP 19 [erts-8.3] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] Eshell V8.3 (abort with ^G) 1> 2、查看了/etc/profile文件,看了一下配置的路径

inserting from erlang into cassandra

丶灬走出姿态 提交于 2019-12-12 17:14:52
问题 I am trying to insert something into cassandra 0.7.6 from Erlang R14B02 (through thrift 0.6.1) I am doing the following: Read record definitions rr(cassandra_types). Connect to cassandra {ok, C}=thrift_client_util:new("localhost", 9160, cassandra_thrift,[{strict_read, false}, {strict_write, false}, {framed, true}]). Try to insert a value (timestamp=1, 2=Quorum) Reply1 = thrift_client:call(C, 'insert', ["existing_keyspace", "new_key",#columnPath{column_family = "existing_column_family", column

Sending message Pid Erlang

天涯浪子 提交于 2019-12-12 16:55:58
问题 I would like to know, how can i send a message to process with erlang. I did start a process and the output shows me that the pid is <0.39.0>. My problem is how can i send a message to this process (<0.39.0>) manually. Anyhelp would be appreciated 回答1: While list_to_pid/1 can indeed be used to construct a PID and use it to send messages its usage is discouraged: This BIF is intended for debugging and for use in the Erlang operating system. It should not be used in application programs. A

while tesing, I got erlang_error: “{badmatch,{error,system_limit}},{module,function,3}”?

此生再无相见时 提交于 2019-12-12 16:16:27
问题 I am doing load testing of my server with number of clients(200, 300, 500, ....3000). For testing I am using windows 64 bit systems and I am running server on one system and clients on another system. All the clients can do connections successfully, but after one minute or two minutes later, server through an erlang:error -> "{badmatch,{error,system_limit}},{module,accept_function,3}" for some server instances and dies those server instances. Can any on have a solution for this ? Thank you in

Getting PID for a process running on a remote node

蹲街弑〆低调 提交于 2019-12-12 14:49:59
问题 I am new to Erlang and we are working on a small scale messaging server. We are trying to build a process registry using Redis ( not planning to use existing once grpoc, global etc due to other business needs ) as a datastore ( store to hold user-id to "node | PID " mapping). When a process starts it register itself with Redis in the form user_id (key) and {node | pid } as value. ( pid is tored as string in redis) example value inserted in redis are "user_abc", {one@mf, "0.37.0>"} Now when I