Hannes Baldursson wrote:
Whoops I'm still in trouble...

I've made great progress though... I've figured out HOW to use the skeleton
app generator, I've figured out where to place my definition files and the
Erlang lib for thrift. I've managed to make the erlang server app (haven't
added any code so far).  I got the server running but it crashed and I
wasn't able to connect to it via a PHP client (Connection refused).

In short I need a proof of concept server that I can call function foo() and
get the string "bar" back to the client.

Could you give me a hand?

Thanks in advance,
Hannes Balduesson

Here's a dump of what erlang gives me. What am I doing wrong?


Eshell V5.5.5  (abort with ^G)
([EMAIL PROTECTED])1>
=PROGRESS REPORT==== 31-Oct-2008::12:27:36 ===
          supervisor: {local,sasl_safe_sup}
             started: [{pid,<0.45.0>},
                       {name,alarm_handler},
                       {mfa,{alarm_handler,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 31-Oct-2008::12:27:36 ===
          supervisor: {local,sasl_safe_sup}
             started: [{pid,<0.46.0>},
                       {name,overload},
                       {mfa,{overload,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 31-Oct-2008::12:27:36 ===
          supervisor: {local,sasl_sup}
             started: [{pid,<0.44.0>},
                       {name,sasl_safe_sup},
                       {mfa,
                           {supervisor,
                               start_link,
                               [{local,sasl_safe_sup},sasl,safe]}},
                       {restart_type,permanent},
                       {shutdown,infinity},
                       {child_type,supervisor}]

=PROGRESS REPORT==== 31-Oct-2008::12:27:36 ===
          supervisor: {local,sasl_sup}
             started: [{pid,<0.47.0>},
                       {name,release_handler},
                       {mfa,{release_handler,start_link,[]}},
                       {restart_type,permanent},
                       {shutdown,2000},
                       {child_type,worker}]

=PROGRESS REPORT==== 31-Oct-2008::12:27:36 ===
         application: sasl
          started_at: '[EMAIL PROTECTED]'

=SUPERVISOR REPORT==== 31-Oct-2008::12:27:36 ===
     Supervisor: {local,session_sup}
     Context:    start_error
     Reason:     {'EXIT',
                     {undef,
                         [{thrift_server,
                              start_link,
                              [8080,sessionServer_thrift,session_service]},
                          {supervisor,do_start_child,2},
                          {supervisor,start_children,3},
                          {supervisor,init_children,2},
                          {gen_server,init_it,6},
                          {proc_lib,init_p,5}]}}
     Offender:   [{pid,undefined},
                  {name,session_service},
                  {mfa,{session_service,start_link,[]}},
                  {restart_type,permanent},
                  {shutdown,2000},
                  {child_type,worker}]

=CRASH REPORT==== 31-Oct-2008::12:27:36 ===
  crasher:
    pid: <0.51.0>
    registered_name: []
    error_info: {shutdown,{session_app,start,[normal,[]]}}
    initial_call: {application_master,
                     init,
                     [<0.5.0>,
                      <0.50.0>,
                      {appl_data,
                          session,
                          [],
                          undefined,
                          {session_app,[]},
                          ["session_app","session_sup","session_service"],
                          [],
                          infinity,
                          infinity},
                      normal]}
    ancestors: [<0.50.0>]
    messages: [{'EXIT',<0.52.0>,normal}]
    links: [<0.50.0>,<0.5.0>]
    dictionary: []
    trap_exit: true
    status: running
    heap_size: 610
    stack_size: 21
    reductions: 2058
  neighbours:

=INFO REPORT==== 31-Oct-2008::12:27:36 ===
    application: session
    exited: {shutdown,{session_app,start,[normal,[]]}}
    type: temporary



On Thu, Oct 30, 2008 at 21:12, Suhail Doshi <[EMAIL PROTECTED]>wrote:

Hannes Baldursson wrote:

Hi all,

I'm having some troubles with the Erlang generated code from Thrift. I
might
add that I'm a newbie in using Thrift and got minimal knowledge about
Erlang
but I'm fairly experienced in programming.

I've been looking at the tutorial where in one directory "tutorial/erl/"
there are files called "server.erl" and "server.sh" that seem to be an
implementation of the RPC functions. Am I missing something or doesn't
Thrift generate server stubs based on my definition file?

All the generated files I see are in the gen-erl and I can't see that any
one of them do what server.erl does... am I missing something or do I have
to hand code the "server.erl" file

btw, I will make sure to add your points into the wiki page

Thanks in advance,
Hannes Baldursson



Hi Hannes,

I am very new to thrift too, just started hacking away at it last week.
Fortunately I was lucky to be friends with Todd Lipcon who made the Erlang
bindings for Thrift in the first place. Something very useful is:

http://github.com/toddlipcon/thrift_erl_skel/tree/master

Play around and check it out, should give you a great stepping stone. You
might get stuck make the erlang app, make sure to check where your rpc
directory is pointing to in gen/Makefile.

Suhail


Sure, I can pass on the wealth of knowledge:

Download this:

http://github.com/toddlipcon/thrift_erl_skel/tree/master


First thing you want to do is execute that perl script so do:./make_new_thrift.pl example Example 9090

example - This is name of your thrift file without the extension, a thrift file should be in the same directory as the perl script
Example - Probably the class level name
9090 - port feel free to change it

Make sure you've taken the lib/erl/ directory in the thrift source code and place it in the same directory as the thrift_skel. Run make on it, we need it compiled for this to work.


Next make an rpc directory somewhere, I made mine a directory *above* where my thrift_skel, thrift directories are. Call it whatever you want, I called mine /rpc/. Now you want to edit /example/gen/Makefile. And change the path of RPC_DIR to where you actually have it or you will definitely run into errors.

Now it's fun time, go into your example/src/ and start editting your example_service.erl with any function you want, remember to export it. A simple one would be: add(A,B) -> A+B.
The export at the top of the file below handler_function one would be: add/2

Jump back into root directory of your example folder, not the src folder. Run make. Everytime you change code, you must run make but you do not have to restart your service, Todd made it awesome with code reloading, we'll go into that.

Now run: sudo ./start_example.sh and the service should start running with a pseudo console for you to reload code and even test your own service. Press enter and type: example_service:add(1,3).

Hopefully it works and you see the output of the result.

Sorry if I am babying people in this mailing list, I know some of you could code erlang circles around me but it's geared to people who have no idea what they are doing. Anyway, enjoy. Don't thank me, thank Todd Lipcon who made this and endured a few hours here and there helping me. =)

Sincerely,
Suhail Doshi

Reply via email to