[erlang-questions] Making the step from Erlang to Erlang/OTP

Fredrik Thulin ft@REDACTED
Wed Mar 12 14:03:37 CET 2008


David Mitchell wrote:
> Hello all,
> 
> I'm finding it difficult to jump from "pure" (for want of another
> term) Erlang code to OTP.
> 
> I can see that OTP is what I want to be using, but I'm struggling to
> get my head around taking an existing non-OTP application and
> converting it to run under OTP.
...

Speaking as someone who took that step a couple of years ago (hand 
firmly held by OTP knowledgeable person at the time), I would like to 
suggest that you

   1) create an OTP supervisor that is started when you start your
      program ("program" to not risk overloading the word
      "application" that means something specific in Erlang/OTP)

   2) convert the first of your existing persistent processes into a
      gen_server. OTP gen_servers are what handles your typical

      receive
         Foo ->
            act_on(Foo)
         after 100 ->
            timeout
      end

      and use the supervisor from 1) to start the gen_server.

This is the way I took into OTP land, and I'd say I turned out alright ;)

/Fredrik



More information about the erlang-questions mailing list