<NME> iphp_MW_Worker.php
<BEF> <?php
class iphp_MW_Worker
{
	public $id = '';
	public $link = null;
	private $mw = null;
	private $name = '';
	
	function __construct($mw){
		global $argv;
		$this->name = basename($argv[0]);
		$this->mw = $mw;
	}

	function init($ip, $port){
		$this->link = new iphp_MW_Link();
		if(!$this->link->connect($ip, $port)){
			throw new Exception("manager gone");
		}
		if($resp['type'] == 'ok'){
			#Logger::debug("worker[{$this->id}] started");
		}else{
			throw new Exception("bad response");
		}
		if($resp['type'] == 'ok'){
			//Logger::debug("[{$this->name}] worker[{$this->id}] started");
		}else{
			throw new Exception("bad response");
		}
	}

	function run($manager){
				break;
			}
			if($req['type'] == 'quit'){
				#Logger::debug("receive quit message");
				break;
			}
			
			if($req['type'] == 'quit'){
				#Logger::debug("[{$this->name}] receive quit");
				break;
			}
			
			$job = $req['data'];
			#Logger::debug("[{$this->name}] process job: " . json_encode($job));
			
			// process job...
			#sleep(mt_rand(1, 2));
			$error = '';
			try{
				$ret = $this->mw->worker($job['data']);
			}catch(Exception $e){
				$ret = false;
				$error = $e->getMessage();
				Logger::error("[{$this->name}] worker throw exception: " . $e->getMessage());
			}
			
			$result = array(
				'id' => $job['id'],
				'time' => $job['time'],
				'error' => $error,
				'result' => $ret,
			);
			$ret = $this->link->send('result', $result);
			if(!$ret){
				Logger::debug("[{$this->name}] worker[{$this->id}] send result error.");
				break;
			}
		}
		//Logger::debug("[{$this->name}] worker[{$this->id}] quit");
	}
}

<MSG> update

<DFF> @@ -18,7 +18,7 @@ class iphp_MW_Worker
 			throw new Exception("manager gone");
 		}
 		if($resp['type'] == 'ok'){
-			#Logger::debug("worker[{$this->id}] started");
+			Logger::debug("worker[{$this->id}] started");
 		}else{
 			throw new Exception("bad response");
 		}
@@ -33,7 +33,7 @@ class iphp_MW_Worker
 				break;
 			}
 			if($req['type'] == 'quit'){
-				#Logger::debug("receive quit message");
+				Logger::debug("receive quit message");
 				break;
 			}
 			

update