Lloyd R. Prentice
Lloyd R. Prentice

Reputation: 4837

Erlang: why does -behaviour(supervisor) give me "undefined callback function" error?

When I try to compile an OTP supervisor module that starts like this:

-module(gridz_sup).

-behaviour(supervisor).

-export([start_link/0, start_child/2]).

-define(SERVER, ?MODULE).

yada, yada...

I get the following error:

gridz_sup.erl:9: Warning: undefined callback function init/1 (behaviour 'supervisor').

Can some kind soul point out the error of my ways?

Many thanks,

LRP

Upvotes: 3

Views: 1226

Answers (1)

Jan Henry Nystrom
Jan Henry Nystrom

Reputation: 1065

When implementing a behaviour call back module there is a number of mandatory call back functions that has to be defined and exported. If not you will get the warning as you saw. For the supervisor behaviour there is only one mandatory call back function init which takes one argument.

Upvotes: 8

Related Questions