|
2 | 2 | $config = [ |
3 | 3 | 'id' => 'yii2-queue-app', |
4 | 4 | 'basePath' => dirname(__DIR__), |
5 | | - 'vendorPath' => dirname(dirname(dirname(__DIR__))) . '/vendor', |
| 5 | + 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', |
6 | 6 | 'bootstrap' => [ |
7 | 7 | 'fileQueue', |
8 | 8 | 'mysqlQueue', |
|
22 | 22 | ], |
23 | 23 | 'mysql' => [ |
24 | 24 | 'class' => \yii\db\Connection::class, |
25 | | - 'dsn' => 'mysql:host=localhost;dbname=yii2_queue_test', |
26 | | - 'username' => 'root', |
27 | | - 'password' => '', |
| 25 | + 'dsn' => sprintf( |
| 26 | + 'mysql:host=%s;port=%s;dbname=%s', |
| 27 | + getenv('MYSQL_HOST') ?: 'localhost', |
| 28 | + getenv('MYSQL_PORT') ?: 3306, |
| 29 | + getenv('MYSQL_DATABASE') ?: 'yii2_queue_test' |
| 30 | + ), |
| 31 | + 'username' => getenv('MYSQL_USER') ?: 'root', |
| 32 | + 'password' => getenv('MYSQL_PASSWORD') ?: '', |
28 | 33 | 'charset' => 'utf8', |
29 | 34 | 'attributes' => [ |
30 | 35 | PDO::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode = "STRICT_ALL_TABLES"', |
|
49 | 54 | ], |
50 | 55 | 'pgsql' => [ |
51 | 56 | 'class' => \yii\db\Connection::class, |
52 | | - 'dsn' => 'pgsql:host=localhost;dbname=yii2_queue_test', |
53 | | - 'username' => 'postgres', |
54 | | - 'password' => '', |
| 57 | + 'dsn' => sprintf( |
| 58 | + 'pgsql:host=%s;port=%s;dbname=%s', |
| 59 | + getenv('POSTGRES_HOST') ?: 'localhost', |
| 60 | + getenv('POSTGRES_PORT') ?: 5432, |
| 61 | + getenv('POSTGRES_DB') ?: 'yii2_queue_test' |
| 62 | + ), |
| 63 | + 'username' => getenv('POSTGRES_USER') ?: 'postgres', |
| 64 | + 'password' => getenv('POSTGRES_PASSWORD') ?: '', |
55 | 65 | 'charset' => 'utf8', |
56 | 66 | ], |
57 | 67 | 'pgsqlQueue' => [ |
|
65 | 75 | ], |
66 | 76 | 'redis' => [ |
67 | 77 | 'class' => \yii\redis\Connection::class, |
68 | | - 'database' => 2, |
| 78 | + 'hostname' => getenv('REDIS_HOST') ?: 'localhost', |
| 79 | + 'port' => getenv('REDIS_PORT') ?: 6379, |
| 80 | + 'database' => getenv('REDIS_DB') ?: 1, |
69 | 81 | ], |
70 | 82 | 'redisQueue' => [ |
71 | 83 | 'class' => \yii\queue\redis\Queue::class, |
72 | 84 | ], |
73 | 85 | 'amqpQueue' => [ |
74 | 86 | 'class' => \yii\queue\amqp\Queue::class, |
| 87 | + 'host' => getenv('RABBITMQ_HOST') ?: 'localhost', |
| 88 | + 'port' => getenv('RABBITMQ_PORT') ?: 5672, |
| 89 | + 'user' => getenv('RABBITMQ_USER') ?: 'guest', |
| 90 | + 'password' => getenv('RABBITMQ_PASSWORD') ?: 'guest', |
75 | 91 | 'queueName' => 'queue-basic', |
76 | 92 | 'exchangeName' => 'exchange-basic', |
77 | 93 | ], |
78 | 94 | 'amqpInteropQueue' => [ |
79 | 95 | 'class' => \yii\queue\amqp_interop\Queue::class, |
| 96 | + 'host' => getenv('RABBITMQ_HOST') ?: 'localhost', |
| 97 | + 'port' => getenv('RABBITMQ_PORT') ?: 5672, |
| 98 | + 'user' => getenv('RABBITMQ_USER') ?: 'guest', |
| 99 | + 'password' => getenv('RABBITMQ_PASSWORD') ?: 'guest', |
80 | 100 | 'queueName' => 'queue-interop', |
81 | 101 | 'exchangeName' => 'exchange-interop', |
82 | 102 | ], |
83 | 103 | 'beanstalkQueue' => [ |
84 | 104 | 'class' => \yii\queue\beanstalk\Queue::class, |
| 105 | + 'host' => getenv('BEANSTALK_HOST') ?: 'localhost', |
| 106 | + 'port' => getenv('BEANSTALK_PORT') ?: 11300, |
85 | 107 | ], |
86 | 108 | ], |
87 | 109 | ]; |
|
90 | 112 | $config['bootstrap'][] = 'gearmanQueue'; |
91 | 113 | $config['components']['gearmanQueue'] = [ |
92 | 114 | 'class' => \yii\queue\gearman\Queue::class, |
| 115 | + 'host' => getenv('GEARMAN_HOST') ?: 'localhost', |
| 116 | + 'port' => getenv('GEARMAN_PORT') ?: 4730, |
93 | 117 | ]; |
94 | 118 | } |
95 | 119 |
|
|
0 commit comments