erlang

Docker实操:1.制作Erlang开发环境镜像

ぐ巨炮叔叔 提交于 2019-12-05 03:14:13
1.安装docker toolbox 1)在官网上下载OS上需要的docker toolbox。 2)下载完成后,像安装OS上的软件一样来安装docker toolbox。安装完成后,你会发现此时安装了一个virtualbox。同时也安装了docker的相关命令,比如docker-machine等。 2.安装docker虚拟机 利用上述步骤安装的docker-machine来安装一个docker虚拟机,名字为default,命令是docker-machine run default. 此时就会创建一个虚拟机叫做default。 3.连接虚拟机 这里直接给出命令了:docker-machine ssh default.如果你再宿主机上安装了多个虚拟机,你可以使用docker-machine ls来查看。同时,你也可以使用docker-machine env default来查看虚拟机的信息。 4.拉取镜像 通过第三步以后,你已经连接上虚拟机了。因此,你可以直接在里面来拉取docker的镜像了。我这里拉取了ubuntu最新的镜像。命令是docker pull ubuntu ,针对国内下载镜像很慢的情况,国内的DaoCloud做了一个镜像,在使用他的镜像之前,你需要在虚拟机上使用命令来安装他的一个加速器,安装加速器后,速度蹭蹭往上加快。命令是:curl -sSL https://get

Does it make sense to use a pool of Actors?

爱⌒轻易说出口 提交于 2019-12-05 03:02:34
I'm just learning, and really liking, the Actor pattern. I'm using Scala right now, but I'm interested in the architectural style in general, as it's used in Scala, Erlang, Groovy, etc. The case I'm thinking of is where I need to do things concurrently, such as, let's say "run a job". With threading, I would create a thread pool and a blocking queue, and have each thread poll the blocking queue, and process jobs as they came in and out of the queue. With actors, what's the best way to handle this? Does it make sense to create a pool of actors, and somehow send messages to them containing or

Doubly linked data structures in erlang

旧街凉风 提交于 2019-12-05 02:51:56
问题 Hi I want to make a tree that keeps two-way references between parent and children. But it seems impossible to achive since when I create first object I do not have the other one yet therefore cannot have a reference to it. Here is some sample code. -record(node,{name,children,root}). main()-> A = #node{name="node-A", children=[B], %variable B is unbound root=nil}, B = #node{name="node-B", children=[], root=A}, Tree = A. Another example to this problem would be implementing a doubly linked

Erlang socket send timeout never happens

二次信任 提交于 2019-12-05 02:49:12
问题 I am implementing a TCP Server in Erlang which talks to mobile phone clients. Mobile phones get offline a lot, so the server must be able to detect it. Hence I want the server to send messages to clients with a timeout, so that when the timeout happens the connection is closed and the client are marked as offline. I used this listen option on the server: [{certfile, "cert.pem"}, {keyfile, "key.pem"}, {reuseaddr, true}, {active, false}, {send_timeout, 10000}] After I set up the connection

rebar unable to get dependency from github

大憨熊 提交于 2019-12-05 02:32:22
I am unable to get any dependency from github using rebar. rebar.config file: {sub_dirs, ["rel"]}. {deps_dir, ["deps"]}. {erl_opts, [debug_info]}. {deps, [ {thrift_erl, "0.5.0", {git, "git://github.com/xslogic/thrift_erl", "HEAD"}}, {eleveldb, "1.0.1", {git, "git://github.com/xslogic/eleveldb", "HEAD"}} ]}. When I do ./rebar compile I get: Dependency not available: thrift_erl-0.5.0 ({git, "git://github.com/xslogic/thrift_erl", "HEAD"}) Dependency not available: eleveldb-1.0.1 ({git, "git://github.com/xslogic/eleveldb", "HEAD"}) It keeps looking for DEP_NAME with a dash at the end and can't

erlang rebar escriptize & nifs

寵の児 提交于 2019-12-05 02:31:12
I can use nif's if I write the escript myself, however when I use rebar escriptize the nif functions cannot be found. I think it is because *.so objects are not getting packed like beam files. Here is an simple example; rebar.config : {deps, [ {'jiffy', "", {git, "https://github.com/davisp/jiffy.git", {branch, master}}} ]}. {escript_incl_apps, [jiffy]}. %% I tried this to see what happens if the so got in there but didn't help {escript_incl_extra, [{"deps/jiffy/priv/jiffy.so", "/path/to/my/proj"}]}. test.erl : -module(test). -export([main/1]). main(_Args) -> jiffy:decode(<<"1">>), ok. rebar

dbg:tracer visualizing recursive functions e.g. by indenting

一曲冷凌霜 提交于 2019-12-05 02:00:12
问题 I have the problem debugging an complicated recursive function I'm using the idiom: dbg:tracer(),dbg:p(all,c),dbg:tpl(Mod,Fun1,x),dbg:tpl(Mod,Fun2,x)... This gives me a flat list of calls to all functions where it is very hard to find out which return belongs to which call. Is there a easy way to make this more readable e.g. by indenting. I could just post process the text produced and indent for each call, and outdent for each return, but this sounds not very elegant to me. 回答1: In the

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

喜你入骨 提交于 2019-12-05 01:55:02
I need to convert {{2012, 9, 21}, {13, 21, 11}} into timestamp(). How can I do that? Thank you. 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}. You might use this to_timestamp({{Year,Month,Day},{Hours,Minutes,Seconds}}) -> (calendar:datetime_to_gregorian_seconds( {{Year,Month,Day},{Hours,Minutes,Seconds}} ) - 62167219200)*1000000; This is part of module from this Github/Arboreus 来源: https://stackoverflow.com/questions

Java - Hot deployment

隐身守侯 提交于 2019-12-05 01:53:27
问题 Recently, I was reading book about Erlang which has hot deployment feature. The deployment can be done without bringing the system down. All the existing requests will be handled by old version of code and all the new request after deployment will be served by the new code. In these case, both the versions of code available in runtime for sometime till all the old requests are served. Is there any approach in Java where we can keep 2 versions of jar files? Is there any app/web servers support

What challenges promote the use of parallel/concurrent architectures?

倖福魔咒の 提交于 2019-12-05 01:51:18
问题 I am quite excited by the possibility of using languages which have parallelism / concurrency built in, such as stackless python and erlang, and have a firm belief that we'll all have to move in that direction before too long - or will want to because it will be a good/easy way to get to scalability and performance. However, I am so used to thinking about solutions in a linear/serial/OOP/functional way that I am struggling to cast any of my domain problems in a way that merits using