Commit 06862162 authored by chenchuanwen's avatar chenchuanwen

bridgestart

parent 5b37a670
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向public的上一级 define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向public的上一级
require_once APPLICATION_PATH . '/scripts/crontab/common.php'; require_once APPLICATION_PATH . '/scripts/crontab/common.php';
$conf = \Yaf\Registry::get('config')->get('redis.database.params'); $conf = \Yaf\Registry::get('config')->get('redis.database.params');
$http = new swoole_http_server("0.0.0.0", 9501); $http = new swoole_http_server("0.0.0.0", 9501);
$http->on('request', function ($request, $response) { $http->on('request', function ($request, $response) {
try{ try{
......
...@@ -3,7 +3,7 @@ define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向 ...@@ -3,7 +3,7 @@ define("APPLICATION_PATH", realpath(dirname(__FILE__) . '/../../../')); //指向
require APPLICATION_PATH . '/scripts/crontab/baseCli.php'; require APPLICATION_PATH . '/scripts/crontab/baseCli.php';
require APPLICATION_PATH . '/scripts/crontab/common.php'; require APPLICATION_PATH . '/scripts/crontab/common.php';
error_reporting(E_ALL ^ E_NOTICE); error_reporting(E_ALL ^ E_NOTICE);
class runRedisPush class bridgeStart
{ {
/* config */ /* config */
const LISTEN = "tcp://192.168.2.15:5555"; const LISTEN = "tcp://192.168.2.15:5555";
...@@ -42,6 +42,10 @@ class runRedisPush ...@@ -42,6 +42,10 @@ class runRedisPush
return (getmypid()); return (getmypid());
} }
} }
public function callback($instance,$channelName,$message){
$orderService=\Business\Order\OrderServiceModel::getInstance();
$orderService->testPush($message);
}
protected function status(){ protected function status(){
if (file_exists($this->pidfile)) { if (file_exists($this->pidfile)) {
$pid = file_get_contents($this->pidfile); $pid = file_get_contents($this->pidfile);
...@@ -50,13 +54,10 @@ class runRedisPush ...@@ -50,13 +54,10 @@ class runRedisPush
printf("%s haven't running\n", $this->argv[0]); printf("%s haven't running\n", $this->argv[0]);
} }
} }
public function callback($instance,$channelName,$message){
$orderService=\Business\Order\OrderServiceModel::getInstance();
$orderService->testPush($message);
}
private function start() private function start()
{ {
$pid = $this->daemon(); $pid = $this->daemon();
$conf = \Yaf\Registry::get('config')->get('redis.database.params');
$http = new swoole_http_server("0.0.0.0", 9501); $http = new swoole_http_server("0.0.0.0", 9501);
$http->on('request', function ($request, $response) { $http->on('request', function ($request, $response) {
try{ try{
...@@ -93,6 +94,13 @@ class runRedisPush ...@@ -93,6 +94,13 @@ class runRedisPush
$http->start(); $http->start();
} }
private function reload(){
if (file_exists($this->pidfile)) {
$pid = file_get_contents($this->pidfile);
//posix_kill(posix_getpid(), SIGHUP);
posix_kill($pid, SIGHUP);
}
}
protected function restart(){ protected function restart(){
$this->stop(); $this->stop();
$this->start(); $this->start();
...@@ -112,9 +120,10 @@ class runRedisPush ...@@ -112,9 +120,10 @@ class runRedisPush
{ {
printf("%s start | stop | help | restart | reload \n", $proc); printf("%s start | stop | help | restart | reload \n", $proc);
} }
private $argv;
public function main($argv) public function main($argv)
{ {
$this->argv=$argv;
if (count($argv) < 2) { if (count($argv) < 2) {
printf("please input help parameter\n"); printf("please input help parameter\n");
exit(); exit();
...@@ -126,11 +135,16 @@ class runRedisPush ...@@ -126,11 +135,16 @@ class runRedisPush
$this->start(); $this->start();
} else if($argv[1] === 'restart'){ } else if($argv[1] === 'restart'){
$this->restart(); $this->restart();
}else{ }else if($argv[1] === 'status'){
$this->status();
}else if($argv[1]==='reload'){
$this->reload();
}
else{
$this->help($argv[0]); $this->help($argv[0]);
} }
} }
} }
$cgse = new runRedisPush(); $cgse = new bridgeStart();
$cgse->main($argv); $cgse->main($argv);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment