Re: Stopping/Restarting instance from the command line

Dev WO <[email protected]> Wed, 25 Aug 2004 15:35:45 +0200
Newsgroups gmane.comp.web.webobjects.admin
Message-ID <[email protected]>
> Xavier,
>
> Why are you trying to replace WOTask/Monitor with an admin app of your  
> own?
Basically we're trying to make a complete web tool to monitor WOApp,  
write to the Apache config file, etc. With Monitor, we couldn't manage  
different users, they'll all see and can modify all the applications.  
In addition to that, we're fully committed to standard compliance and  
accessibility, and Monitor isn't HTML compliant (not too many error  
though) and is less than accessible. And maybe we'll need to provide  
this tool in another language than english.
>
> I remember someone posting to the list about having written a WOTask  
> replacement. The motivation was to work around a specific limitation  
> of the WOTask mecanism. A running app has a special thread sending  
> lifebeats to the WOTask daemon. Thus WOTask knows if the application  
> is alive. The catch is that there may be situation where the lifebeat  
> thread is alive while other thread have died or locked up. The idea  
> was to build a monitoring system that periodically requests an actual  
> direct action page from the application. As long as the application is  
> able to fulfill that request it is also able to handle user requests.
I understand the logic of this. It would be so much easier if Monitor  
was an open application;) or at least if we could consume it as a web  
service.
>
> However if you are merely trying to reproduce the exact behavior of  
> WOTask/Monitor you might just as well us the existing - but  
> undocumented - communication protocols between WOTask and the  
> applications it manages. The code below notifies WOTaskD about  
> application termination:
>
> 			if (lifebeatEnabled())
> 			{
>         		lifeBeatMessage.append("GET  
> /cgi-bin/WebObjects/wotaskd.woa/wlb?willStop");
>      	   	lifeBeatMessage.append("&");
>         		lifeBeatMessage.append(name());
>         		lifeBeatMessage.append("&");
>         		lifeBeatMessage.append(hostAddress().getHostName());
>         		lifeBeatMessage.append("&");
>         		lifeBeatMessage.append(port());
>         		lifeBeatMessage.append(" HTTP/1.0\r\n\r\n");
>
> 				// Send the lifebeat
> 				try
> 				{
> 					Socket 			socket 			= new Socket(hostAddress(),  
> lifebeatDestinationPort(), hostAddress(), 0);
> 					OutputStream 	outputstream 	= socket.getOutputStream();
> 				
> 					socket.setTcpNoDelay(true);
> 					socket.setSoLinger(false, 0);
> 				
> 					outputstream.write(lifeBeatMessage.toString().getBytes("UTF8"));
> 					outputstream.flush();
> 					socket.close();
> 				}
> 				catch (Exception exception)
> 				{
> 					NSLog.debug.appendln("Exception while notifying wotaskd: " +  
> exception);
> 				}
> 			}

Could you point me to other resources like this one? is there an  
unofficial documentation?
>
> With direct actions it should be reasonably easy to contact a running  
> application:
>
> - directly at the port number passed as WOPort argument if direct  
> connect is enabled
> - through the adaptor knowing that the URL can be derived from  
> application name and instance number
Thanks a lot Pierre, I hope we'll be able to get through this...I wish  
there were some more features for WOApplication that would allow us to  
directly use it to manage other application.
>
> Pierre
>
> -----Original Message-----
> From: Anazys-WO [mailto:[email protected]]
> Sent: Tuesday, August 24, 2004 5:54 PM
> To: Pierre Bernard
> Cc: [email protected]; [email protected];
> [email protected]
> Subject: Re: Stopping/Restarting instance from the command line
>
>
> Hi Pierre, sorry for the delay
>
>> Runtime.exec() can be a bit tricky to get to work in a conistent
>> manner on different platforms. But one you got it up and running it
>> probably is the cleanest way to start a WebObjects application.
>> Question is if this is really what you want to do. At some point you
>> are going to need information from WOTask like port number, output
>> path ...
> You are right, I'll need these information too.
>>  which you may not want to hardcode/duplicate. That is unless you are
>> trying to replace WOTask/Monitor for managing applications.
> It's exactly what I want to do, I'm trying to do a "new" Monitor.
> That's why I was wondering about WOApplication. It can do pretty much
> whatever I need to, but I don't know if (and How) I can call
> WOApplication from AdminApp.woa to start (stop, ect) appliclient1.woa.
> I mean how to initialize appliclient1.woa from within AdminApp.woa.
> Do you know how I could do it?
>>
>> As for interacting with a running application you have plenty of
>> choices. As I said you could tap into the protocol used by WOTask.
> Do you have any pointer to documentation on how  to do it?
>>  Or, as Karl suggested, you could create your own set of direct
>> actions. If you do so you would do good to check the client IP in  
>> your  > DA code. You might also use plain sockets or RMI. This might  
>> be easier  > to keep behind the firewall. You could also use the file  
>> system for
>> communication. An extra thread in your application could check the
>> modification date of a config file. Upon change it would read in the
>> new instructions.
> Sounds quite complicated to me;)
>
> Don't hesitate to tell me if you think I'm going the wrong way:)
>
> Xavier
>
> PS: I can launch an app using the command-line, but I have no mean to
> keep in contact with the instance, like I cannot know if the instance
> is alive, tell it to stop accepting sessions, modify it's scheduled
> etc...(I need to do it without Monitor).
>
>>
>> Pierre.
>>
>> -----Original Message-----
>> From: Hsu [mailto:[email protected]]
>> Sent: Thursday, August 19, 2004 7:04 PM
>> To: Dev WO
>> Cc: Pierre Bernard; [email protected];
>> [email protected]
>> Subject: Re: Stopping/Restarting instance from the command line
>>
>>
>> To start another application, just use Runtime.exec() and friends to
>> run the shell script inside the woa.
>>
>> To stop applications, you can have a custom communication's protocol
>> that calls the WOApplication methods, or you can use direct actions
>> (which is what Monitor/wotaskd use). Be careful with DA's - they may  
>> be
>> accessible through the webserver.
>>
>> Karl
>>
>> On Aug 19, 2004, at 9:07 AM, Dev WO wrote:
>>
>>> Thanks Pierre, but I don't know exactly how to do it:(
>>> So I started to relax a little and re-evaluate what I wanted to do.
>>> I found that with WOApplication I could start, stop and do pretty  
>>> much
>>> everything with my application/instance, so it looks like what I  
>>> need.
>>> BUT it looks like WOApplication only affect the application that make
>>> the call... and I don't want to do that, I'd like to call
>>> WOApplication (from application A) to start application B. Is this
>>> possible? I couldn't find something like setPath to tell  
>>> WOApplication
>>> which .woa to start.
>>>
>>> Thanks for helping me clarify this;)
>>>
>>> Xavier
>>>
>>>> Well, you could reverse-engineer the communication protocol between
>>>> Monitor/WOTaskd and the WO applications.
>>>>
>>>> Actually with the appropriate network tools you should be able to  
>>>> see
>>>> the calls made. These are DirectAction-like calls which you might be
>>>> able to issue with tools like wget or curl. At worst you would have
>>>> to write a small Java app.
>>>>
>>>> Pierre
>>>>
>>>> -----Original Message-----
>>>> From: [email protected]
>>>> [mailto:[email protected]]On Behalf Of Dev WO
>>>> Sent: Wednesday, August 18, 2004 3:44 PM
>>>> To: [email protected];  
>>>> [email protected]
>>>> Subject: Stopping/Restarting instance from the command line
>>>>
>>>>
>>>> Hi,
>>>> I was wondering if there is a more cleaver way to stop and restart  
>>>> an
>>>> instances from the command line than killing the PID?
>>>> Thanks for your knowledge;)
>>>>
>>>> Xavier
>>>> _______________________________________________
>>>> webobjects-deploy mailing list | [email protected]
>>>> Help/Unsubscribe/Archives:
>>>> http://www.lists.apple.com/mailman/listinfo/webobjects-deploy
>>>> Do not post admin requests to the list. They will be ignored.
>>>>
>>>>
>>>>
>>>> ******************************************************************** 
>>>> * >>> *
>>>> This email and any files transmitted with it are intended solely for
>>>> the use of the individual or entity to whom they are addressed.
>>>> If you have received this email in error please notify the sender
>>>> of this message. ([email protected])
>>>> This email message has been checked for the presence of computer
>>>> viruses; however this protection does not ensure this message is
>>>> virus free.
>>>> Banque centrale du Luxembourg; Tel ++352-4774-1; http://www.bcl.lu
>>>> ******************************************************************** 
>>>> * >>> *
>>>>
>>>>
>>>
>>> _______________________________________________
>>> WebObjects-admin mailing list
>>> [email protected]
>>> http://www.omnigroup.com/mailman/listinfo/webobjects-admin
>>>
>> --
>>
>> Invention: Man creates the automobile to go places without walking.
>> Progress: Man creates the treadmill for walking without going places.
>>
>> Homepage:
>>       http://homepage.mac.com/khsu/index.html
>>
>>
>>
>> **********************************************************************
>> This email and any files transmitted with it are intended solely for
>> the use of the individual or entity to whom they are addressed.
>> If you have received this email in error please notify the sender
>> of this message. ([email protected])
>> This email message has been checked for the presence of computer
>> viruses; however this protection does not ensure this message is
>> virus free.
>> Banque centrale du Luxembourg; Tel ++352-4774-1; http://www.bcl.lu
>> **********************************************************************
>> _______________________________________________
>> webobjects-deploy mailing list | [email protected]
>> Help/Unsubscribe/Archives:
>> http://www.lists.apple.com/mailman/listinfo/webobjects-deploy
>> Do not post admin requests to the list. They will be ignored.
>>
>>
>
>
>
> **********************************************************************
> This email and any files transmitted with it are intended solely for
> the use of the individual or entity to whom they are addressed.
> If you have received this email in error please notify the sender
> of this message. ([email protected])
> This email message has been checked for the presence of computer
> viruses; however this protection does not ensure this message is
> virus free.
> Banque centrale du Luxembourg; Tel ++352-4774-1; http://www.bcl.lu
> **********************************************************************
>
>