[erlang-questions] target system

Tim Watson <>
Mon Mar 5 10:32:21 CET 2012


Hi Ramu,

Frankly this doesn't make a lot of sense to me, but from I gather you're trying to create a release (aka target system) and want to know how to start your 'project' up without using a gen_server. OTP is predicated on the concept of an 'Application' - see http://erlang.org/doc/design_principles/applications.html for details - and without this, you will be hard pressed to build a release. Your application does not have to be built using gen_server, but there ought to be a top level supervisor or at a minimum, a top level process that is to be run.

Aside: think about this like you would a Java or .NET (or python/ruby/perl/etc if you) program. You will start the program from some main class (or script) and this must block the main thread in order to prevent the program from terminating - so you will spawn some background thread(s) to do the actual work - and in many cases if you're running inside of some kind of container (like a web application server e.g., tomcat/weblogic, IIS, tornado, etc) or framework (like WCF/fuse/camel/mule/twisted/event-machine/etc) so you just implement the 'callback' part of the contract and the framework/container does the rest.

It is necessary to have your code running in a process, and whilst you can forgo using gen_servers and supervisors if you really wish to, you will still need to spawn a process in which your application shall run. There is such a thing as a library application, which has no start module. You can achieve this by removing the 'mod' element from your application resource file, like so:

%% foobar.app
{application, foobar,
 [
  {description, ""},
  {vsn, "0.0.1"},
  {applications, [kernel, stdlib]}
 ]}.

In this case however, because your library (i.e., an 'inactive' application) has no startup function - because there is no application callback module - there is no way to initialise the start state. This option is really intended for library code that has no state, hence the name.

I would strongly suggest reading the documentation, especially the system and design principles, before trying to build a target system in a non-standard way. I would also highly recommend reading http://learnyousomeerlang.com/, especially the section http://learnyousomeerlang.com/building-applications-with-otp, before proceeding.

Cheers
Tim 

On 5 Mar 2012, at 05:19, raamu eppa wrote:

> Hi,
> 
> In my erlang files there is no option for start OTP gen_server.But i want to create my project as a target system.
> Is there any option for creating target system without using OTP gen_server.
> Iam starting my project as,
> mongodb:init([]).
> sendmail:send_message("your option").
> 
> Thanks,
> Ramu.
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120305/74b2d3e9/attachment.html>


More information about the erlang-questions mailing list