From: akonsu <ak...@gm...> - 2013-09-13 04:02:42
|
Hello, I have a yapp that I wrote (which so far does nothing, I am only learning), and I need to start only one and no more instances of my yapp for all my yaws instances (I am planning to have yaws behind a load balancer). I do not know how to do it. So far I have in my yaws.config: runmod = my_yapp <server localhost> port = 8000 listen = 0.0.0.0 docroot = /home/akonsu/my_app appmods = </, my_appmod> </server> as far as I understand runmod starts my module on the server startup, but I have multiple servers, I do not need that. Does this mean I have to start my app manually, I mean by an external means? thanks for any help Konstantin |
From: Steve V. <vi...@ie...> - 2013-09-13 13:29:37
|
On Fri, Sep 13, 2013 at 12:02 AM, akonsu <ak...@gm...> wrote: > Hello, > > I have a yapp that I wrote (which so far does nothing, I am only > learning), and I need to start only one and no more instances of my yapp > for all my yaws instances (I am planning to have yaws behind a load > balancer). > > I do not know how to do it. So far I have in my yaws.config: > > runmod = my_yapp > > <server localhost> > port = 8000 > listen = 0.0.0.0 > docroot = /home/akonsu/my_app > appmods = </, my_appmod> > </server> > > as far as I understand runmod starts my module on the server startup, but > I have multiple servers, I do not need that. Does this mean I have to start > my app manually, I mean by an external means? > It's not really going to work -- Yaws makes local calls into the yapp, so it must be co-located with Yaws itself. I'm guessing you were planning for your yapp to be your Twitter client -- if so, I recommend just writing it as a regular Erlang application and running it in its own OS process, and writing an appmod for Yaws that connects to it via Distributed Erlang. The appmod could just send its pid to register itself with the Twitter client, and when the Twitter client got data from Twitter, it could just use that pid along with normal Erlang messaging to send that data to all registered Yaws processes, which in turn would send the data out to their HTTP clients. --steve |
From: akonsu <ak...@gm...> - 2013-09-13 18:17:50
|
Thank you Steve, your responses helped me a lot. If I send Pids of yaws processes to my standalone process, how do I know when these yaws processes are gone? Does yaws send any messages on disconnects? I suppose I can also check for errors when sending messages to registered Pids. I just do not know what the established Erlang practice is in this situation. Does OTP have any behaviours for that? Konstantin 2013/9/13 Steve Vinoski <vi...@ie...> > > > > On Fri, Sep 13, 2013 at 12:02 AM, akonsu <ak...@gm...> wrote: > >> Hello, >> >> I have a yapp that I wrote (which so far does nothing, I am only >> learning), and I need to start only one and no more instances of my yapp >> for all my yaws instances (I am planning to have yaws behind a load >> balancer). >> >> I do not know how to do it. So far I have in my yaws.config: >> >> runmod = my_yapp >> >> <server localhost> >> port = 8000 >> listen = 0.0.0.0 >> docroot = /home/akonsu/my_app >> appmods = </, my_appmod> >> </server> >> >> as far as I understand runmod starts my module on the server startup, but >> I have multiple servers, I do not need that. Does this mean I have to start >> my app manually, I mean by an external means? >> > > It's not really going to work -- Yaws makes local calls into the yapp, so > it must be co-located with Yaws itself. > > I'm guessing you were planning for your yapp to be your Twitter client -- > if so, I recommend just writing it as a regular Erlang application and > running it in its own OS process, and writing an appmod for Yaws that > connects to it via Distributed Erlang. The appmod could just send its pid > to register itself with the Twitter client, and when the Twitter client got > data from Twitter, it could just use that pid along with normal Erlang > messaging to send that data to all registered Yaws processes, which in turn > would send the data out to their HTTP clients. > > --steve > |
From: Steve V. <vi...@ie...> - 2013-09-13 18:43:18
|
I recommend that you use Erlang's monitoring facility to know when those processes exit. See http://www.erlang.org/doc/man/erlang.html#monitor-2 for details. --steve On Fri, Sep 13, 2013 at 2:17 PM, akonsu <ak...@gm...> wrote: > Thank you Steve, your responses helped me a lot. If I send Pids of yaws > processes to my standalone process, how do I know when these yaws processes > are gone? Does yaws send any messages on disconnects? I suppose I can also > check for errors when sending messages to registered Pids. I just do not > know what the established Erlang practice is in this situation. Does OTP > have any behaviours for that? > Konstantin > > > > 2013/9/13 Steve Vinoski <vi...@ie...> > >> >> >> >> On Fri, Sep 13, 2013 at 12:02 AM, akonsu <ak...@gm...> wrote: >> >>> Hello, >>> >>> I have a yapp that I wrote (which so far does nothing, I am only >>> learning), and I need to start only one and no more instances of my yapp >>> for all my yaws instances (I am planning to have yaws behind a load >>> balancer). >>> >>> I do not know how to do it. So far I have in my yaws.config: >>> >>> runmod = my_yapp >>> >>> <server localhost> >>> port = 8000 >>> listen = 0.0.0.0 >>> docroot = /home/akonsu/my_app >>> appmods = </, my_appmod> >>> </server> >>> >>> as far as I understand runmod starts my module on the server startup, >>> but I have multiple servers, I do not need that. Does this mean I have to >>> start my app manually, I mean by an external means? >>> >> >> It's not really going to work -- Yaws makes local calls into the yapp, so >> it must be co-located with Yaws itself. >> >> I'm guessing you were planning for your yapp to be your Twitter client -- >> if so, I recommend just writing it as a regular Erlang application and >> running it in its own OS process, and writing an appmod for Yaws that >> connects to it via Distributed Erlang. The appmod could just send its pid >> to register itself with the Twitter client, and when the Twitter client got >> data from Twitter, it could just use that pid along with normal Erlang >> messaging to send that data to all registered Yaws processes, which in turn >> would send the data out to their HTTP clients. >> >> --steve >> > > |