New topic: 

how to handle Empty Service appications, Run and Stop method

<http://forums.realsoftware.com/viewtopic.php?t=30549>

       Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic         Author  
Message       unclepauly           Post subject: how to handle Empty Service 
appications, Run and Stop methodPosted: Mon Oct 19, 2009 9:11 am                
        
Joined: Fri Oct 16, 2009 1:36 pm
Posts: 2              hello,

im developing a service application on a Mac. i have added logging so i can see 
whats happening and when. all i want the service to do is create and listen on 
an IPCSocket when the service starts, and close the IPCSocket when the service 
stops. the service application has, amongst other things, a Run method and a 
Stop method. i am using the "launchctl load" command to start my service and 
the "launchctl unload" command to stop my service, and i assumed that the Run 
method would be called when the service is loaded and the Stop method would be 
called when the service is unloaded - but it seems not.

as i understand it, when the Run method ends, the Stop method is then 
immediately called. i believe it happens this way due to my logging. when i do 
the "launchctl load" command, i can see the Run method being hit - and then i 
can see the Stop method being hit, which surely is not right ? so my initial 
idea to prevent this was to put a while loop in the Run method. this will loop 
forever, calling DoEvents. i thought that this would prevent the Run method 
from ending - which it does - and i also thought that it would allow the Stop 
method to be called when i do the "launchctl unload" command - which it does 
not.

what am i doing wrong ? i just want the Run method to be called once on start 
up, and the Stop method called once when the service stops. here is the code 
that i have got so far (taken the logging out) :

[Run method]
Code:
//at start-up i create a new IPCSocket and set it as a property (MyIPCSock) so 
that it is global to the app.
Dim ipcsock as new IPCSocket
MyIPCSock = ipcsock
MyIPCSock.Path = "mypath"
MyIPCSock.Listen

//while loop was here

Quit(0)

//at this point the Stop method gets called automatically



[Stop method]
Code:
//the Stop method has been called - close the IPCSocket
MyIPCSock.Close



thank you.   
                            Top            Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]     
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to