Image start-up hooks

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

Image start-up hooks

Michel Onoff
Hi,

is there a way to register arbitrary code to be run at image start-up
and shutdown?

Thanks
Michel

Reply | Threaded
Open this post in threaded view
|

Re: Image start-up hooks

Sven Van Caekenberghe-2
Hi Michel,

> On 13 Dec 2016, at 10:25, Michel Onoff <[hidden email]> wrote:
>
> Hi,
>
> is there a way to register arbitrary code to be run at image start-up and shutdown?
>
> Thanks
> Michel

Sure, that is possible and common.

Have a look at the 'system startup' protocol of TBehavior (as implemented by classes) and look for the startUp & shutDownmessages.

There is also the 'snapshot and quit' protocol of SmalltalkImage with messages like addDeferredStartupAction: and addToStartUpList:
 
In newer Pharo images (5+ I think), SessionManager is your friend, a cleaner rewrite.

Sven



Reply | Threaded
Open this post in threaded view
|

Re: Image start-up hooks

Michel Onoff
On 2016-12-13 10:35, Sven Van Caekenberghe wrote:

> Hi Michel,
>
>> On 13 Dec 2016, at 10:25, Michel Onoff <[hidden email]> wrote:
>>
>> Hi,
>>
>> is there a way to register arbitrary code to be run at image start-up and shutdown?
>>
>> Thanks
>> Michel
>
> Sure, that is possible and common.
>
> Have a look at the 'system startup' protocol of TBehavior (as implemented by classes) and look for the startUp & shutDownmessages.
>
> There is also the 'snapshot and quit' protocol of SmalltalkImage with messages like addDeferredStartupAction: and addToStartUpList:
>
> In newer Pharo images (5+ I think), SessionManager is your friend, a cleaner rewrite.
>
> Sven
>
>
>

Thanks Sven, I'll take a look.


Reply | Threaded
Open this post in threaded view
|

Re: Image start-up hooks

Ben Coman
In reply to this post by Michel Onoff
Look at class refs to SessionManager.  I was going to refer you to its class comment but its incomplete. Could someone knowledgeable update the class comment to define what support methods are required and the preferred way to register.  I'm a bit confused.  I'm familiar with #startUp/#shutDown from Delay, but its not obvious from the list of senders which invokes these.
  
I do see TestSessionHandler defines #startup: and the only sender is #runStartup:
But I see it also defines #startupHandler: whose only senders (one step removed) are tests, so how does this method fit into the architecture?

cheers -ben



On Tue, Dec 13, 2016 at 5:25 PM, Michel Onoff <[hidden email]> wrote:
Hi,

is there a way to register arbitrary code to be run at image start-up and shutdown?

Thanks
Michel


Reply | Threaded
Open this post in threaded view
|

Re: Image start-up hooks

Stephane Ducasse-3
Ben 

can you open a ticket and we will ask guille and pablo to write a class comment. 

Stef


On Tue, Dec 13, 2016 at 11:16 AM, Ben Coman <[hidden email]> wrote:
Look at class refs to SessionManager.  I was going to refer you to its class comment but its incomplete. Could someone knowledgeable update the class comment to define what support methods are required and the preferred way to register.  I'm a bit confused.  I'm familiar with #startUp/#shutDown from Delay, but its not obvious from the list of senders which invokes these.
  
I do see TestSessionHandler defines #startup: and the only sender is #runStartup:
But I see it also defines #startupHandler: whose only senders (one step removed) are tests, so how does this method fit into the architecture?

cheers -ben



On Tue, Dec 13, 2016 at 5:25 PM, Michel Onoff <[hidden email]> wrote:
Hi,

is there a way to register arbitrary code to be run at image start-up and shutdown?

Thanks
Michel



Reply | Threaded
Open this post in threaded view
|

Re: Image start-up hooks

Ben Coman
https://pharo.fogbugz.com/f/cases/19463/Improve-SessionManager-class-comment

On Tue, Dec 13, 2016 at 10:08 PM, Stephane Ducasse <[hidden email]> wrote:
Ben 

can you open a ticket and we will ask guille and pablo to write a class comment. 

Stef


On Tue, Dec 13, 2016 at 11:16 AM, Ben Coman <[hidden email]> wrote:
Look at class refs to SessionManager.  I was going to refer you to its class comment but its incomplete. Could someone knowledgeable update the class comment to define what support methods are required and the preferred way to register.  I'm a bit confused.  I'm familiar with #startUp/#shutDown from Delay, but its not obvious from the list of senders which invokes these.
  
I do see TestSessionHandler defines #startup: and the only sender is #runStartup:
But I see it also defines #startupHandler: whose only senders (one step removed) are tests, so how does this method fit into the architecture?

cheers -ben



On Tue, Dec 13, 2016 at 5:25 PM, Michel Onoff <[hidden email]> wrote:
Hi,

is there a way to register arbitrary code to be run at image start-up and shutdown?

Thanks
Michel