English 中文(简体)
Erlang/OTP, 如何在不发生崩溃的情况下信号程序启动错误
原标题:Erlang/OTP, how to signal an application startup error without a crash

So I have this application that has a process that requires some gen_servers to be alive somewhere else in the cluster.
If they are up it just works, if they are not, my gen_server fails in init with {error,Reason}, this propagates through my supervisor into my applications start function.
The problem is that if I return anything other than {ok,Pid} I get a crash report.

我在这里的意图是以某种方式表明,应用程序无法正常启动,所有进程都处于下行状态,而且由于应用程序不应被视为活动状态,然而,我只能选择返回 {ok, self()} 并看到我的应用程序在不返回或返回 {error, oil} 时以 active 列出,看看它是如何崩溃的:

{gen_server,init_it,6},{proc_lib,init_p_do_apply,3}]}},{ancestors,[rtb_sup,<0.134.0>]},
{messages,[]},{links,[<0.135.0>]},{dictionary,[]},{trap_exit,false},{status,running},
{heap_size,377},{stack_size,24},{reductions,255}],[]]:
"

问题似乎比这个大, 基本上无法告诉应用程序框架该应用程序失败。 它可能看起来像由 < code> 处理的这些事情之一, 由 < code> 程序在 erlan 中死 < / code >, 但允许在 < code> 应用程序上使用 < code> {/ code> 返回值 : start 似乎是一种良好的权衡 。

有暗示吗?

问题回答

应用程序将随时崩溃, 所以应用程序初始时的依赖关系无法提供有用的动态崩溃信息 。

在我读到 rabbitmq 项目源代码之前,它也是一个基于集群的方案。

我认为rabbitmq 已经面临你所说的类似问题,因为集群需要收集相关的 nodes s 应用程序“是活的”信息和memory 水高标记信息,然后作出决定。

它的解决方案是

  1. 要在本地节点注册应用程序的第一个主要进程, 名字在 rabbitmq 系统中是“ rabbbit ”, 您可以在 < code>rabbbit. erl 文件和函数“ start/2” 中找到它。

    start(normal, []) -> case erts_version_check() of ok -> {ok, SupPid} = rabbit_sup:start_link(), true = register(rabbit, self()), print_banner(), [ok = run_boot_step(Step) || Step <- boot_steps()], io:format("~nbroker running~n"), {ok, SupPid}; Error -> Error end.

  2. And the other 4 modules, rabbit_node_monitor.erl, rabbit_memory_monitor.erl, vm_memory_monitor.erl, rabbit_alarm.erl to use two erlang technique, one is monitor process to get "DOWN" message of the registered process, the other is alarm handler to collect these information.





相关问题
Ruby Interpreter crashes with a certain word

Ok, this one s a little ridiculous, and I m almost afraid no one will believe me. But here it goes: I have written a Ruby Rails application that handles content for tons of domains. Now I know this ...

Java HotSpot error

Curious if anyone could help out in regards to a Java HotSpot dump...saw some reference to head over to the Sun Forums, figured I would try here first...below is the dump... # # An unexpected error ...

NSOperation performSelectorOnMainThread crashes

I m calling a NSOperation from a Subview of a NavigationController. MyOperation *op = [[MyOperation alloc] target:self action:@selector(didFinishOperation)]; The Operation loads some data from a ...

Is this kind of crash report useless?

I tried use "PLCrashReport" to collect the crash info then make the app more stable, but turns out that the report is like this(dont even has a call stack,how am I suppose to use it?): The "Exception:...

Xcode crashes with divide by zero

I downloaded urlcache.zip from http://developer.apple.com/iphone/library/samplecode/URLCache/index.html#//apple_ref/doc/uid/DTS40008061 I opened the project in xcode and clicked on urlcacheconection....

热门标签