Erlang supervisor start_child

classic Classic list List threaded Threaded
12 messages Options
shk
Reply | Threaded
Open this post in threaded view
|

Erlang supervisor start_child

shk
Hello,

I write pop3 server. My application:

       root supervisor (one_for_one)  -> listener supervisor(one_for_one) -> fsm supervisor (simple one_for_one) and listener gen_server

I run all supervisors it's ok. When i try to start_child of fsm supervisor 2 or more times i get error: {error,{already_started,<0.324.0>}}

How can i correctly design my supervisors that i can run many gen_fsm child by fsm supervisor.

All code: https://github.com/onlyshk/epmail

Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Erlang supervisor start_child

Alexey Romanov
From documentation of gen_fsm:start_link:

If FsmName={local,Name}, the gen_fsm is registered locally as Name
using register/2. If FsmName={global,GlobalName}, the gen_fsm is
registered globally as GlobalName using global:register_name/2. If no
name is provided, the gen_fsm is not registered.

Since you can't have two processes with same registered name on a
node, you need to provide different names (or no names at all).

Yours, Alexey Romanov



On Sun, Jan 30, 2011 at 4:57 PM, shk <[hidden email]> wrote:

>
> Hello,
>
> I write pop3 server. My application:
>
>       root supervisor (one_for_one)  -> listener supervisor(one_for_one) ->
> fsm supervisor (simple one_for_one) and listener gen_server
>
> I run all supervisors it's ok. When i try to start_child of fsm supervisor 2
> or more times i get error: {error,{already_started,<0.324.0>}}
>
> How can i correctly design my supervisors that i can run many gen_fsm child
> by fsm supervisor.
>
> All code: https://github.com/onlyshk/epmail
>
> Thank you.
> --
> View this message in context: http://erlang.2086793.n4.nabble.com/Erlang-supervisor-start-child-tp3247153p3247153.html
> Sent from the Erlang Questions mailing list archive at Nabble.com.
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:[hidden email]
>
>

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

shk
Reply | Threaded
Open this post in threaded view
|

Re: Erlang supervisor start_child

shk
On Sun, Jan 30, 2011 at 4:13 PM, Alexey Romanov
<[hidden email]> wrote:

> Yours, Alexey Romanov
>
>
>
> On Sun, Jan 30, 2011 at 7:05 PM, Alexander Kuleshov
> <[hidden email]> wrote:
>>>Since you can't have two processes with same registered name on a
>>>node, you need to provide different names (or no names at all).
>>
>> Hello,
>>
>> If i havent gen_fsm name, how can i gen_fsm:send_event to this gen_fsm?
>>
>
> By the pid (which you can get from supervisor:which_children).
>

Thank you for reply.

In popd_listener i try:

pop_fsm_sup:start_child(Sock, [], []),
[{_,_, Child, _}] = supervisor:which_children(pop_fsm_sup),

When i connect with first client it's ok, but when i try to connect
with second client i see error:

Error in process <0.815.0> on node 'emacs@myhost' with exit value:
{{badmatch,[{undefined,<0.818.0>,worker,[popd_fsm]},{undefined,<0.819.0>,worker,[popd_fsm]}]},[{popd_listener,accept,1}]}

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Erlang supervisor start_child

Alexey Romanov
[{_,_, Child, _}] = ...

assumes that the right side only has one child.


Yours, Alexey Romanov



On Sun, Jan 30, 2011 at 7:30 PM, Alexander Kuleshov
<[hidden email]> wrote:

> On Sun, Jan 30, 2011 at 4:13 PM, Alexey Romanov
> <[hidden email]> wrote:
>> Yours, Alexey Romanov
>>
>>
>>
>> On Sun, Jan 30, 2011 at 7:05 PM, Alexander Kuleshov
>> <[hidden email]> wrote:
>>>>Since you can't have two processes with same registered name on a
>>>>node, you need to provide different names (or no names at all).
>>>
>>> Hello,
>>>
>>> If i havent gen_fsm name, how can i gen_fsm:send_event to this gen_fsm?
>>>
>>
>> By the pid (which you can get from supervisor:which_children).
>>
>
> Thank you for reply.
>
> In popd_listener i try:
>
> pop_fsm_sup:start_child(Sock, [], []),
> [{_,_, Child, _}] = supervisor:which_children(pop_fsm_sup),
>
> When i connect with first client it's ok, but when i try to connect
> with second client i see error:
>
> Error in process <0.815.0> on node 'emacs@myhost' with exit value:
> {{badmatch,[{undefined,<0.818.0>,worker,[popd_fsm]},{undefined,<0.819.0>,worker,[popd_fsm]}]},[{popd_listener,accept,1}]}
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:[hidden email]
>
>

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

shk
Reply | Threaded
Open this post in threaded view
|

Re: Erlang supervisor start_child

shk
On Sun, Jan 30, 2011 at 4:37 PM, Alexey Romanov
<[hidden email]> wrote:

> [{_,_, Child, _}] = ...
>
> assumes that the right side only has one child.
>
>
> Yours, Alexey Romanov
>
>
>
> On Sun, Jan 30, 2011 at 7:30 PM, Alexander Kuleshov
> <[hidden email]> wrote:
>> On Sun, Jan 30, 2011 at 4:13 PM, Alexey Romanov
>> <[hidden email]> wrote:
>>> Yours, Alexey Romanov
>>>
>>>
>>>
>>> On Sun, Jan 30, 2011 at 7:05 PM, Alexander Kuleshov
>>> <[hidden email]> wrote:
>>>>>Since you can't have two processes with same registered name on a
>>>>>node, you need to provide different names (or no names at all).
>>>>
>>>> Hello,
>>>>
>>>> If i havent gen_fsm name, how can i gen_fsm:send_event to this gen_fsm?
>>>>
>>>
>>> By the pid (which you can get from supervisor:which_children).
>>>
>>
>> Thank you for reply.
>>
>> In popd_listener i try:
>>
>> pop_fsm_sup:start_child(Sock, [], []),
>> [{_,_, Child, _}] = supervisor:which_children(pop_fsm_sup),
>>
>> When i connect with first client it's ok, but when i try to connect
>> with second client i see error:
>>
>> Error in process <0.815.0> on node 'emacs@myhost' with exit value:
>> {{badmatch,[{undefined,<0.818.0>,worker,[popd_fsm]},{undefined,<0.819.0>,worker,[popd_fsm]}]},[{popd_listener,accept,1}]}
>>
>> ________________________________________________________________
>> erlang-questions (at) erlang.org mailing list.
>> See http://www.erlang.org/faq.html
>> To unsubscribe; mailto:[hidden email]
>>
>>
>

Now all works.

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|

Android Tablet and Erlang (+Java)

Zabrane Mickael
Does someone knows a good "Android tablet" than can be used for small Erlang development?
________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Android Tablet and Erlang (+Java)

Lukas Larsson-3
Hi!

A colleague of mine has gotten Erlang to work on the Samsung Galaxy tablet.
Don't know if it is better or worse than any else, but it works anyways.

Lukas

On Mon, Jan 31, 2011 at 7:05 AM, Zabrane Mickael <[hidden email]> wrote:

> Does someone knows a good "Android tablet" than can be used for small
> Erlang development?
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:[hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Android Tablet and Erlang (+Java)

Zabrane Mickael
Thanks Lucas. Any  other experiences guys?

Le 31 janv. 2011 à 16:10, Lukas Larsson a écrit :

> Hi!
>
> A colleague of mine has gotten Erlang to work on the Samsung Galaxy tablet.
> Don't know if it is better or worse than any else, but it works anyways.
>
> Lukas


________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Android Tablet and Erlang (+Java)

Felix Hamilton
Recently got Ubuntu running on an Archos 10.1 'android tablet'. Havent
actually tried to get erlang compiled natively on an android device,
however ...

On Mon, Jan 31, 2011 at 7:19 AM, Zabrane Mickael <[hidden email]> wrote:

> Thanks Lucas. Any  other experiences guys?
>
> Le 31 janv. 2011 à 16:10, Lukas Larsson a écrit :
>
>> Hi!
>>
>> A colleague of mine has gotten Erlang to work on the Samsung Galaxy tablet.
>> Don't know if it is better or worse than any else, but it works anyways.
>>
>> Lukas
>
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:[hidden email]
>
>

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Android Tablet and Erlang (+Java)

Zabrane Mickael
Le 31 janv. 2011 à 18:58, Felix Hamilton a écrit :

> Recently got Ubuntu running on an Archos 10.1 'android tablet'. Havent
> actually tried to get erlang compiled natively on an android device,
> however ...


Cool. Thanks Felix!


________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Android Tablet and Erlang (+Java)

Garret Smith-2
You can also take a look at Erlang for Android at
http://www.burbas.se/artiklar/erlang-for-the-android-plattform/

I have gotten as far as installing it and running a few commands in
the interactive interpreter on my HTC Evo running the popular
Cyanogenmod ROM.

-Garret Smith

On Mon, Jan 31, 2011 at 11:05 AM, Zabrane Mickael <[hidden email]> wrote:

> Le 31 janv. 2011 à 18:58, Felix Hamilton a écrit :
>
>> Recently got Ubuntu running on an Archos 10.1 'android tablet'. Havent
>> actually tried to get erlang compiled natively on an android device,
>> however ...
>
>
> Cool. Thanks Felix!
>
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:[hidden email]
>
>

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Android Tablet and Erlang (+Java)

Zabrane Mickael
Thanks for the link Garret.


Le 1 févr. 2011 à 20:20, Garret Smith a écrit :

> You can also take a look at Erlang for Android at
> http://www.burbas.se/artiklar/erlang-for-the-android-plattform/
>
> I have gotten as far as installing it and running a few commands in
> the interactive interpreter on my HTC Evo running the popular
> Cyanogenmod ROM.
>
> -Garret Smith
>
> On Mon, Jan 31, 2011 at 11:05 AM, Zabrane Mickael <[hidden email]> wrote:
>> Le 31 janv. 2011 à 18:58, Felix Hamilton a écrit :
>>
>>> Recently got Ubuntu running on an Archos 10.1 'android tablet'. Havent
>>> actually tried to get erlang compiled natively on an android device,
>>> however ...
>>
>>
>> Cool. Thanks Felix!
>>
>>
>> ________________________________________________________________
>> erlang-questions (at) erlang.org mailing list.
>> See http://www.erlang.org/faq.html
>> To unsubscribe; mailto:[hidden email]
>>
>>

Regards,
Zabrane


________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:[hidden email]