<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
Hi,<div><br></div><div>I have an application (let's call it dev_mon) that is responsible for listening to, processing and emitting events on a hardware interface. This application contains 3 supervisors and many registered gen_server processes. Currently we have a single interface that requires supervision.</div><div><br></div><div>Future hardware revisions will expose multiple interfaces that requires dev_mon to monitor. Obviously I can handle this in the code, however I believe a better solution would be to have multiple instances of dev_mon for each interface.</div><div><br></div><div>In this case I would have application dev_mon_if1, dev_mon_if2, dev_mon_if3 etc. </div><div><br></div><div>The only way I can think of to implement this is to write 3 separate application files (in their own directories) along with their associated Erlang app files. For example:</div><div><br></div><div>dev_mon_if1/ebin/dev_mon_if1.erl</div><div>dev_mon_if1/ebin/dev_mon_if1.app</div><div><br></div><div><div>dev_mon_if2/ebin/dev_mon_if2.erl</div><div>dev_mon_if2/ebin/dev_mon_if2.app</div></div><div><br></div><div>dev_mon_if/ebin/..all the other beam files shared between all instances..</div><div><br></div><div>The ".app" file would contain an env property that ensures the registered supervisors and gen_servers are unique (e.g. if1, if2 etc).</div><div><br></div><div>i.e. not do:</div><div><br></div><div>







<p class="p1">start_link() <span class="s1">-></span></p>
<p class="p1"><span style="font-size: 10pt; ">    gen_server:start_link({local, </span><span class="s3" style="font-size: 10pt; ">?MODULE</span><span style="font-size: 10pt; ">}, </span><span class="s3" style="font-size: 10pt; ">?MODULE</span><span style="font-size: 10pt; ">, [], []).</span></p><p class="p1"><br></p><p class="p1">Instead to:</p><p class="p1"><br></p><p class="p1"><p class="p1">start_link(RegName) <span class="s1">-></span></p><p class="p1"><span style="font-size: 10pt; ">    gen_server:start_link({local, </span><span class="s3" style="font-size: 10pt; ">RegName</span><span style="font-size: 10pt; ">}, </span><span class="s3" style="font-size: 10pt; ">?MODULE</span><span style="font-size: 10pt; ">, [], []).</span></p></p><p class="p1"><br></p><p class="p1">Where RegName is an atom like 'if1_monitorapp'.</p><p class="p1"><br></p><p class="p1">Question: Is there a better way to do this?</p><p class="p1"><br></p><p class="p1">Thanks</p><p class="p1"><br></p><p class="p1">Matt</p><p class="p1"><br></p></div>                                       </div></body>
</html>