• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Monitoring a shell process.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Monitoring a shell process.


  • Subject: Re: Monitoring a shell process.
  • From: Vince DeMarco <email@hidden>
  • Date: Thu, 5 Jul 2001 16:25:04 -0700

On Thursday, July 5, 2001, at 01:08 PM, Isaac Horton wrote:

Is it possible to monitor a daemon for changes? For instance. Say I had a
cocoa application that was a wrapper for Apache. The wrapper allows for you
to stop and start the Apache Server. My problem is monitoring Apache incase
someone decides to stop/start apache via telnet, and then updating the UI to
reflect the new state of httpd. If that is not possible, then is possible to
monitor a file for changes(i.e.:httpd.pid). I am not partial either way.
From the lists that I've looked on, it doesn't seem as if NSNotification
allows for this kind of monitoring. Any help would be greatly appreciated.


Following up to my own mail again. Just use NSURL to fetch something from the webserver if the page comes back the server is up. real easy.

Allocate a NSURL then call the resourceDataUsingCache: on the URL to fetch the data, if data comes back all is well.

There is also

- (void)loadResourceDataNotifyingClient:(id)client usingCache:(BOOL)shouldUseCache; // Starts an asynchronous load of the data, registering delegate to receive notification. Only one such background load can proceed at a time.

which will call the delegate with these methods

@interface NSObject(NSURLClient)
- (void)URL:(NSURL *)sender resourceDataDidBecomeAvailable:(NSData *)newBytes;
- (void)URLResourceDidFinishLoading:(NSURL *)sender;
- (void)URLResourceDidCancelLoading:(NSURL *)sender;
- (void)URL:(NSURL *)sender resourceDidFailLoadingWithReason:(NSString *)reason;
@end


This should do everything you want.

vince


References: 
 >Monitoring a shell process. (From: Isaac Horton <email@hidden>)

  • Prev by Date: Re: Monitoring a shell process.
  • Next by Date: Re: NSProgressIndicator - hiding/visible
  • Previous by thread: Re: Monitoring a shell process.
  • Next by thread: Re: Monitoring a shell process.
  • Index(es):
    • Date
    • Thread