start/stop applications without a callback module

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

start/stop applications without a callback module

Xavier Noria
Trying to get the vocabulary right for OTP applications without a callback module.

Does the application controller spawn an application master process for applications without callback modules? If yes, with what purpose? Do you still call that "starting" the application even though there is no `start/2` callback to invoke?

Are applications without callback modules also "stopped" in some sense? I mean, do you use the verb "stop" for them even though there is no `stop/1` callback to invoke? And if yes, what does "stopping" do?

Is there an official or common term to refer to "application without a callback module", and "application with a callback module"?


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: start/stop applications without a callback module

Loïc Hoguin-3
On 01/01/2018 08:43 PM, Xavier Noria wrote:
> Trying to get the vocabulary right for OTP applications without a
> callback module.
>
> Does the application controller spawn an application master process for
> applications without callback modules? If yes, with what purpose? Do you
> still call that "starting" the application even though there is no
> `start/2` callback to invoke?

All applications can be started.

> Are applications without callback modules also "stopped" in some sense?
> I mean, do you use the verb "stop" for them even though there is no
> `stop/1` callback to invoke? And if yes, what does "stopping" do?

All applications can also be stopped.

For library applications (those without a callback module) it doesn't do
a whole lot, just registers the application as being started (or not)
and triggers some events for SASL and other.

> Is there an official or common term to refer to "application without a
> callback module", and "application with a callback module"?

Library application and application, I don't think the latter has a
specific name.

All details are in this chapter:
http://erlang.org/doc/design_principles/applications.html

--
Loïc Hoguin
https://ninenines.eu
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: start/stop applications without a callback module

Xavier Noria
Awesome, thanks Loïc!

On Mon, 1 Jan 2018 at 20:58, Loïc Hoguin <[hidden email]> wrote:
On 01/01/2018 08:43 PM, Xavier Noria wrote:
> Trying to get the vocabulary right for OTP applications without a
> callback module.
>
> Does the application controller spawn an application master process for
> applications without callback modules? If yes, with what purpose? Do you
> still call that "starting" the application even though there is no
> `start/2` callback to invoke?

All applications can be started.

> Are applications without callback modules also "stopped" in some sense?
> I mean, do you use the verb "stop" for them even though there is no
> `stop/1` callback to invoke? And if yes, what does "stopping" do?

All applications can also be stopped.

For library applications (those without a callback module) it doesn't do
a whole lot, just registers the application as being started (or not)
and triggers some events for SASL and other.

> Is there an official or common term to refer to "application without a
> callback module", and "application with a callback module"?

Library application and application, I don't think the latter has a
specific name.

All details are in this chapter:
http://erlang.org/doc/design_principles/applications.html

--
Loïc Hoguin
https://ninenines.eu
--
Sent from Gmail Mobile

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: start/stop applications without a callback module

Richard Carlsson-3
In reply to this post by Loïc Hoguin-3
2018-01-01 20:58 GMT+01:00 Loïc Hoguin <[hidden email]>:
On 01/01/2018 08:43 PM, Xavier Noria wrote:
Is there an official or common term to refer to "application without a callback module", and "application with a callback module"?

Library application and application, I don't think the latter has a specific name.

For our book (Erlang & OTP in Action), we chose to call them "active applications". Not sure if it's caught on anywhere.

    /Richard 


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: start/stop applications without a callback module

Xavier Noria
On Mon, Jan 1, 2018 at 10:37 PM, Richard Carlsson <[hidden email]> wrote:

2018-01-01 20:58 GMT+01:00 Loïc Hoguin <[hidden email]>:
On 01/01/2018 08:43 PM, Xavier Noria wrote:
Is there an official or common term to refer to "application without a callback module", and "application with a callback module"?

Library application and application, I don't think the latter has a specific name.

For our book (Erlang & OTP in Action), we chose to call them "active applications". Not sure if it's caught on anywhere.

I see Erlang in Anger uses "regular applications".
 

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: start/stop applications without a callback module

Xavier Noria
If library applications are started and stopped, this paragraph in the official OTP intro to applications is accurate

When you have written code implementing some specific functionality you might want to make the code into an application, that is, a component that can be started and stopped as a unit, and which can also be reused in other systems.

but the next one says

To do this, create an application callback module, and describe how the application is to be started and stopped.

and that may mislead the reader I think. To start, stop, and reuse and application, you do not need to create an application callback module. You need if you want run custom code when it starts or stops.

Should it be reworded? (Could volunteer a patch.)


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: start/stop applications without a callback module

Xavier Noria
The rewording I have in mind would be to sharply distinguish starting/stopping *applications* from starting/stopping their supervision tree if there is any, and from callback invocation. Also, to make more explicit the existence of library and regular/active applications.

For example, define that starting an application means (needs review):

1. (Guessing) The application controller makes sure all applications specified in the application resource file are started.
2. The application controller spawns an application master process for the application.
3. The application master becomes the group leader of all the application processes.
4. (Regular applications only) The application master calls `start/2` in the callback module if there is one, and stores the returned PID for later use.

(Don't know if firing SASL events is worth being documented, I see generally they don't seem to be.)

In particular, you know who the group leader is when `start/2` runs. And it is obvious that there are things going on regardless of the existence of a callback module.

Stopping an application means (needs review):

1. (Regular applications only) The application master shuts down the top supervisor using the PID stored when the application started.
2. (Regular applications only) The application master invokes the `stop/1` callback of the application callback module.
3. The application master process is shut down (by the application controller?).
4. <<Termination logic depending on the application type goes here>>

It could also be explicitly said that unless stated otherwise, from then on an "application" means a "regular application".

Are there factual errors? Makes sense?


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions