Console_Deamon
[ class tree: Console_Deamon ] [ index: Console_Deamon ] [ all elements ]

Class: Console_Deamon_Abstract

Source Location: /library/Console/Deamon/Abstract.php

Class Overview

Console_Application_Abstract
   |
   --Console_Deamon_Abstract

Class which is running in a loop.


Author(s):

Copyright:

  • Copyright (c) 2009 Sven Strittmatter

Methods


Inherited Variables

Inherited Methods

Class: Console_Application_Abstract

Console_Application_Abstract::__construct()
On construction time a sapiCheck is done for CLI sapi.
Console_Application_Abstract::echoMsg()
Echoes a string appended with PHP_EOL.
Console_Application_Abstract::execute()
Template method. Try to run some method stubs in this order:
Console_Application_Abstract::findConsoleParameters()
This method listens by default to the console parameters -v and -h.
Console_Application_Abstract::getHelpMessage()
Returns a help message. Its called by default object behavier, if you suply -h to the script. By default it returns a line break formatted help message like:
Console_Application_Abstract::getUsage()
Returns a usage string like:
Console_Application_Abstract::iniSet()
This method wraps the php internal ini_set() that way, that it returns the old value.
Console_Application_Abstract::isExecuted()
Returns whether the application object is executed or not.
Console_Application_Abstract::isPcntlEnabled()
Console_Application_Abstract::isVerbose()
Returns whether the application object is verbose or not.
Console_Application_Abstract::onError()
This method is called if in the three followed methods a exception was
Console_Application_Abstract::registerSignalHandlers()
Registers some signal handlers:
Console_Application_Abstract::run()
You need to implement this method. Put your stuff to do here.
Console_Application_Abstract::setExecuted()
Sets object executed.
Console_Application_Abstract::setPhpEnviroment()
Sets the the php enviroment by ini settings to a proper default.
Console_Application_Abstract::setUp()
Template method stub. Overwrite this method to hook the set up phase of your script. This method is called after Console_Application_Abstract::findConsoleParameters(), unless it returns false. And before Console_Application_Abstract::run().
Console_Application_Abstract::signalHangUp()
Signal handler registered by Console_Application_Abstract::registerSignalHandlers().
Console_Application_Abstract::signalInt()
Signal handler registered by Console_Application_Abstract::registerSignalHandlers().
Console_Application_Abstract::signalTerm()
Signal handler registered by Console_Application_Abstract::registerSignalHandlers().
Console_Application_Abstract::tearDown()
Template method stub. Overwrite this method to hook the tear down phase of your script. This method is called after Console_Application_Abstract::run(), unless any exception was throwed.

Class Details

[line 44]
Class which is running in a loop.



Tags:

copyright:  Copyright (c) 2009 Sven Strittmatter
abstract:  
uses:  Console_Exception
uses:  Console_Application_Abstract


[ Top ]


Class Methods


method breakLoop [line 148]

void breakLoop( )

Signals the object to do no more loop cycles.

After the actual call to self::doLoopCycle() has finished self::onBreakLoop() will be called.




Tags:

access:  protected


[ Top ]

method doLoopCycle [line 141]

void doLoopCycle( )

You need to implement this method with your loop code.

This method is called periodicly until self::breakLoop() is called.

Important is, that after self::breakLoop() this method runs until it returns. If you want to break out from your loop method directly after setting the demaon to break the loop, you need to return:

  1.  protected function onPostLoop({
  2.       // some work ...
  3.  
  4.       if ($something{
  5.           // We break out imediately.
  6.           // some other work will not be executed
  7.           self::breakLoop();
  8.           return;
  9.       }
  10.  
  11.       if ($somethingElse{
  12.           // We only break the loop.
  13.           // This method will not be executed anymore.
  14.           // But some other work will be executed the last time!
  15.           self::breakLoop();
  16.       }
  17.  
  18.       // some other work ...
  19.  }




Tags:

abstract:  
access:  protected


[ Top ]

method onBreakLoop [line 100]

void onBreakLoop( )

Overwrite this method to hook the moment the internal breakLoop flag is set true by the script.



Tags:

access:  protected


[ Top ]

method onPostLoop [line 108]

void onPostLoop( )

Overwrite this method to hook the phase after the loop. This Method is called imediately after self::onBreakLoop(). But before Console_Application_Abstract::tearDown().



Tags:

access:  protected


[ Top ]

method onPreLoop [line 93]

void onPreLoop( )

Overwrite this method to hook the pre loop phase.

This method is called first before the loop. But after Console_Application_Abstract::setUp().




Tags:

access:  protected


[ Top ]

method run [line 70]

void run( )

Template method from Console_Application_Abstract.

This method runs the method doLoopCycle() which you must implement in your deamon class implementation.




Tags:

see:  Console_Application_Abstract
final:  
access:  protected


Overrides Console_Application_Abstract::run() (You need to implement this method. Put your stuff to do here.)

[ Top ]

method signalInt [line 168]

void signalInt( int $signal)

Bind the signal SIG_INT to brek the loop.



Tags:

access:  public


Overrides Console_Application_Abstract::signalInt() (Signal handler registered by Console_Application_Abstract::registerSignalHandlers().)

Parameters:

int   $signal  

[ Top ]

method signalTerm [line 158]

void signalTerm( int $signal)

Bind the signal SIG_TERM to brek the loop.



Tags:

access:  public


Overrides Console_Application_Abstract::signalTerm() (Signal handler registered by Console_Application_Abstract::registerSignalHandlers().)

Parameters:

int   $signal  

[ Top ]


Documentation generated on Mon, 17 Aug 2009 15:51:54 +0200 by phpDocumentor 1.4.2