<div dir="ltr"><div><div><div><div><div>Hi Rad,<br><br></div>First of all Thank you so much for immediate reply.<br><br></div>uclient worker start method:<br><br><br><br>-module(uclient_worker).<br>-behaviour(gen_server).<br><br><span style="background-color:rgb(0,255,0)">-export([start_link/1]).<br><br>-export([init/1, handle_call/3, handle_cast/2, handle_info/2,<br>         terminate/2, code_change/3]).<br><br>-export([fire/0]).<br><br>-export([add_subscriber/4, spawn_subscriber/3]).<br><br>-include_lib("amqp_client/include/amqp_client.hrl").<br><br>-record(state, {channel,java_port :: port(),java_node :: atom(),queuen,nofs}).<br><br>-define(RKFormat,<br>        "~4.10.0B.~2.10.0B.~2.10.0B.~1.10.0B.~2.10.0B.~2.10.0B.~2.10.0B").<br><br><br>start_link(Pars) -><br>    %%file:write_file("/tmp/rabbit.txt", Pars, [append]),<br>    gen_server:start_link({global, ?MODULE}, ?MODULE, Pars, []).<br><br>%---------------------------<br>% Gen Server Implementation<br>% --------------------------<br><br>init(Pars) -></span><br><br><br></div>Regarding to CHILD in supervisor:<br><br></div>actually my initial supervisor is :<br>%%%%%%%%<br>-module(uclient_sup).<br><br>-behaviour(supervisor).<br><br>-export([start_link/0, init/1]).<br><br>start_link() -><br>    supervisor:start_link({local, ?MODULE}, ?MODULE, _Arg = []).<br><br>init([]) -><br>    {ok, {{one_for_one, 1, 10},<br>          [{uclient_worker,<br>            {uclient_<span style="background-color:rgb(255,255,0)"><span style></span></span>worker, start_link, [{<<"callmgr">> , 3}]},<br>            permanent,<br>            10,<br>            worker,<br>            [uclient_worker]}<br>          ]}}.<span style="background-color:rgb(0,255,255)"><span style></span></span><br><span style="background-color:rgb(243,243,243)"><span style>%%%%%%%%%%%%%<br><br><br></span></span></div><div><span style="background-color:rgb(243,243,243)"><span style>But i changed above code for invoking multiple worker under supervisor based on conditions.<br></span></span></div><div><span style="background-color:rgb(243,243,243)"><span style>In that process i just changed code using CHILD.<br><br></span></span></div><div><span style="background-color:rgb(243,243,243)"><span style>Regards,<br></span></span></div><div><span style="background-color:rgb(243,243,243)"><span style>Harsha<br></span></span></div><span style="background-color:rgb(255,255,0)"><span style><span style="background-color:rgb(243,243,243)"></span></span></span><div><div><div><span style="background-color:rgb(255,255,0)"><span style><br></span></span><div><div><br></div></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 26, 2015 at 9:41 PM, Rad Gruchalski <span dir="ltr"><<a href="mailto:radek@gruchalski.com" target="_blank">radek@gruchalski.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                <div>
                    Can you show start_link of the <span style="font-size:12.800000190734863px;background-color:rgb(0,255,255)">uclient_worker</span>?</div><div>
                
                
                


<p style="font-family:Helvetica;font-size:10pt;margin-bottom:0cm">
                
                
                


</p><p style="font-family:Helvetica;font-size:10pt;margin-bottom:0cm">
                
                
                


</p><p style="margin-bottom:0cm">
                
                
                


</p><p style="margin-bottom:0cm"><font color="#000000"><font face="Helvetica, sans-serif"><font style="font-size:9pt">Kind
regards,
<br>Radek
Gruchalski<br>
</font></font></font><font face="Helvetica, sans-serif"><font style="font-size:9pt"><a href="mailto:radek@gruchalski.com" target="_blank">radek@gruchalski.com</a><a href="mailto:radek@gruchalski.com" target="_blank">
</a></font></font><font color="#0084d1"><font face="Helvetica, sans-serif"><font style="font-size:9pt"><br></font></font></font><a href="http://de.linkedin.com/in/radgruchalski/" target="_blank"><font color="#0084d1"><font face="Helvetica, sans-serif"><font style="font-size:9pt">de.linkedin.com/in/radgruchalski/</font></font></font></a><font color="#000000"><font face="Helvetica, sans-serif"><font style="font-size:9pt"><br><br></font></font></font><font color="#878787"><font face="Helvetica, sans-serif"><font style="font-size:8pt"><b>Confidentiality:<br></b></font></font></font><font color="#878787"><font face="Helvetica, sans-serif"><font style="font-size:8pt">This
communication is intended for the above-named person and may be
confidential and/or legally privileged.<br>If it has come to you in
error you must take no action based on it, nor must you copy or show
it to anyone; please delete/destroy and inform the sender
immediately.</font></font></font></p></div><div><div class="h5">
                 
                <p style="color:#a0a0a8">On Thursday, 26 March 2015 at 15:49, harsha sri wrote:</p>
                </div></div><blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px">
                    <span><div><div><div class="h5"><div><div dir="ltr"><div><div><div><div><div><div>Hi,<br><br></div>I am trying to start same worker multiple times in Supervisor but its giving me error.<br></div>Here is my Supervisor:<br><br><br><span style="background-color:rgb(0,255,255)">-module(uclient_sup).<br><br>-behaviour(supervisor).<br><br>-export([start_link/0, init/1]).<br><br>-define(<br>   CHILD(Name, Args),<br>   {Name, {<br>       uclient_worker, start_link, [{<<"callmgr">> , 3}]<br>       }, permanent, 5000, worker, []<br>   }<br>).<br><br>start_link() -><br>    supervisor:start_link({global, ?MODULE}, ?MODULE, _Arg = []).<br><br>init([]) -><br>   Children = [?CHILD("uc1", Address), ?CHILD("uc2", Address)],<br>   {ok, { {one_for_one, 6, 10}, Children }}.</span><br><br></div>I am getting below error:<br><br>Error: {could_not_start,uclient,<br>           {{shutdown,<br>                {failed_to_start_child,"uc2",{already_started,<5169.429.0>}}},<br>            {uclient,start,[normal,[]]}}}<br><br><br></div>Please help me in solving this issue. I am new to erlang.<br><br></div>Thanks & Regards,<br></div>SriHarsha.<br></div>
</div></div></div><div><div>_______________________________________________</div><div>erlang-questions mailing list</div><div><a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a></div><div><a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a></div></div></div></span>
                 
                 
                 
                 
                </blockquote>
                 
                <div>
                    <br>
                </div>
            </blockquote></div><br></div>