yanglin 7 år sedan
förälder
incheckning
79b782eb63

+ 4 - 2
common/config/main.php

@@ -16,8 +16,10 @@ return [
             'port' => 6378,
             'database' => 1,
             'password' => 'airent-redis~123',
-
-
         ],
     ],
+    'params'=>array(
+        // this is used in contact page
+        'rabbithost' => 'localhost',
+    ),
 ];

+ 2 - 2
components/PhpClient.php

@@ -14,7 +14,7 @@ class PhpClient {
     private $result = '';
 
 //   CONST HOST = "172.30.118.225";
-        CONST HOST = "localhost";
+    CONST HOST = "localhost";
 
     CONST PORT = 5673; //默认5672
     CONST USER = "guest"; //用户名
@@ -22,7 +22,7 @@ class PhpClient {
 
     public function __construct() {
         $this->connection = new AMQPStreamConnection(
-            self::HOST, self::PORT, self::USER, self::PASS); //建立连接
+            \Yii::$app->params['rabbithost'], self::PORT, self::USER, self::PASS); //建立连接
 
         $this->channel = $this->connection->channel();
         list($this->callback_queue, ,) = $this->channel->queue_declare(

+ 1 - 1
components/RabbitBase.php

@@ -21,7 +21,7 @@ class RabbitBase {
 
     public function __construct() {
         $this->connection = new AMQPStreamConnection(
-            self::HOST, self::PORT, self::USER, self::PASS); //建立连接
+            \Yii::$app->params['rabbithost'], self::PORT, self::USER, self::PASS); //建立连接
 
         $this->channel = $this->connection->channel();
                 list($this->callback_queue, ,) = $this->channel->queue_declare("", false, false, true, false);

+ 1 - 1
components/RabbitMqServer.php

@@ -92,7 +92,7 @@ class RabbitMqServer{
     protected function connrabbit($conn_args){
 
         $conn = new   AMQPStreamConnection(
-            self::HOST, self::PORT, self::USER, self::PASS); //建立连接
+            \Yii::$app->params['rabbithost'], self::PORT, self::USER, self::PASS); //建立连接
 
         if(!$conn->connectOnConstruct()){
             return false;

+ 1 - 1
console/controllers/RabbitUserController.php

@@ -85,7 +85,7 @@ class RabbitUserController  extends Controller
     {
 
 
-        $connection = new AMQPStreamConnection('localhost', 5673, 'guest', 'guest');
+        $connection = new AMQPStreamConnection(\Yii::$app->params['rabbithost'], 5673, 'guest', 'guest');
 //        $connection = new AMQPStreamConnection('172.30.118.225', 5673, 'guest', 'guest');
         $channel = $connection->channel();
 

+ 1 - 1
console/controllers/RabbittaskController.php

@@ -28,7 +28,7 @@ class RabbittaskController  extends Controller
 {
     public function actionWorker()
     {
-        $connection = new AMQPStreamConnection('localhost', 5673, 'guest', 'guest');
+        $connection = new AMQPStreamConnection(\Yii::$app->params['rabbithost'], 5673, 'guest', 'guest');
         $channel = $connection->channel();
 
         $channel->queue_declare('task_queue', false, true, false, false);