default.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <?php
  2. # 验证dc是否存在,一般在share目录下
  3. $dc = array();
  4. $dc_file = '/share/dc/config.php';
  5. if (is_file($dc_file)) {
  6. $dc = include($dc_file);
  7. }
  8. if (isset($dc['data'])) {
  9. $config['base']['data'] = $dc['data'];
  10. }
  11. $create = false;
  12. if (isset($dc['mysql']['create'])) {
  13. $create = $dc['mysql']['create'];
  14. }
  15. $ip = isset($dc['host']) ? $dc['host'] : '192.168.33.10';
  16. $local = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $ip;
  17. # 数据库配置
  18. $config['database'] = array
  19. (
  20. 'create' => $create,
  21. # 默认数据库配置
  22. 'default' => array
  23. (
  24. 'type' => 'pdo',
  25. 'host' => array
  26. (
  27. 'read' => isset($dc['mysql']) ? $dc['mysql']['host'] : 'web-mysql:3306',
  28. 'update' => isset($dc['mysql']) ? $dc['mysql']['host'] : 'web-mysql:3306',
  29. 'create' => isset($dc['mysql']) ? $dc['mysql']['host_create'] : 'web-mysql:3306',
  30. ),
  31. 'database' => 'wonderful',
  32. 'username' => isset($dc['mysql']) ? $dc['mysql']['username'] : 'root',
  33. 'password' => isset($dc['mysql']) ? $dc['mysql']['password'] : '123456',
  34. 'charset' => 'utf8mb4',
  35. ),
  36. 'session' => array
  37. (
  38. 'type' => 'redis',
  39. 'host' => isset($dc['redis']) ? $dc['redis'][0]['host'] : 'server-redis',
  40. 'port' => isset($dc['redis']) ? $dc['redis'][0]['port'] : '6379',
  41. 'password' => isset($dc['redis']) ? $dc['redis'][0]['password'] : 'dm_redis_123',
  42. )
  43. );
  44. /*
  45. $dc['mysql_user'] = array
  46. (
  47. 'host' => array
  48. (
  49. 'read' => 'web-mysql:3306',
  50. 'update' => 'web-mysql:3306',
  51. ),
  52. 'database' => 'wonderful',
  53. 'username' => 'root',
  54. 'password' => '123456',
  55. );
  56. */
  57. # 设置哪些项目需要切换到弹性数据库
  58. if (isset($dc['mysql_user'])) {
  59. $dc['mysql_user']['charset'] = 'utf8';
  60. $dc['mysql_user']['database'] = 'wonderful_act';
  61. $dc['mysql_user']['type'] = 'pdo';
  62. $config['database']['code'] = $dc['mysql_user'];
  63. $config['database']['act'] = $dc['mysql_user'];
  64. $config['database']['passport'] = $dc['mysql_user'];
  65. $config['database']['pay'] = $dc['mysql_user'];
  66. $config['database']['score'] = $dc['mysql_user'];
  67. $config['database']['wechat'] = $dc['mysql_user'];
  68. }
  69. # 缓存配置
  70. $config['cache'] = array
  71. (
  72. # 启用mysql数据库缓存,这个缓存是根据表名自动生成,dever::load形式和service的all、one形式均自动支持,无需手动添加
  73. 'mysql' => 0,
  74. # 启用页面缓存 会根据当前的url来生成缓存,相当于页面静态化。
  75. 'html' => 0,
  76. # 启用数据级别缓存 这个缓存是程序员自定义的:Dever::cache('name', 'value', 3600);
  77. 'data' => 72000,
  78. # 启用load加载器缓存,一般不加载
  79. 'load' => 0,
  80. # 启用load加载器的远程加载缓存
  81. 'curl' => 0,
  82. # 启用路由缓存
  83. 'route' => 72000,
  84. # 缓存精细控制,根据uri来控制,0则无需缓存
  85. 'routeKey' => array
  86. (
  87. 'journal.buy_action' => 0,
  88. 'journal.code' => 0,
  89. 'passport' => 0,
  90. 'oauth' => 0,
  91. 'cron' => 0,
  92. //'act' => 0,
  93. 'combine' => 0,
  94. 'service_' => 0,
  95. 'vip_' => 0,
  96. 'order.' => 0,
  97. 'buy_home' => 0,
  98. 'buy_my_code' => 0,
  99. 'buy_codedetail' => 0,
  100. 'buy.pay' => 0,
  101. 'journal_v1.top' => 600,
  102. 'journal_v1.read' => 1000,
  103. ),
  104. # 哪些路由中的参数不参与生成缓存的key
  105. 'routeNoParam' => array
  106. (
  107. 'signature' => array
  108. (
  109. 'content.home',
  110. 'content.news',
  111. 'content.up',
  112. 'content.ad',
  113. 'journal.home',
  114. 'journal.getList',
  115. 'journal_v1.home',
  116. 'journal_v1.getList',
  117. 'journal_v1.top',
  118. 'journal_v1.buy',
  119. 'journal_v1.read',
  120. 'buy_list',
  121. 'buy_pay',
  122. ),
  123. 'uid' => array
  124. (
  125. 'content.home',
  126. 'content.news',
  127. 'content.up',
  128. 'content.ad',
  129. 'journal.home',
  130. 'journal.getList',
  131. 'journal_v1.home',
  132. 'journal_v1.getList',
  133. 'journal_v1.top',
  134. 'journal_v1.buy',
  135. 'journal_v1.read',
  136. 'buy_list',
  137. 'buy_pay',
  138. ),
  139. ),
  140. # 缓存清理的参数名,请通过shell=clearcache执行
  141. 'shell' => 'clearcache',
  142. # 是否启用key失效时间记录,启用之后,将会记录每个key的失效时间
  143. 'expire' => true,
  144. # 缓存类型
  145. 'type' => 'redis',//memcache、redis
  146. # 缓存保存方式,支持多个数据源、多台缓存服务器
  147. 'store' => array
  148. (
  149. array
  150. (
  151. 'host' => 'server-redis',
  152. 'port' => '6379',
  153. 'weight' => 100,
  154. 'password' => 'dm_redis_123',
  155. ),
  156. ),
  157. );
  158. if (isset($dc['redis']) && $config['cache']['type'] == 'redis') {
  159. $config['cache']['store'] = $dc['redis'];
  160. }
  161. if (isset($dc['memcache']) && $config['cache']['type'] == 'memcache') {
  162. $config['cache']['store'] = $dc['memcache'];
  163. }
  164. $config['debug'] = array
  165. (
  166. 'log' => false
  167. );
  168. /*
  169. if (DEVER_APP_NAME == 'source') {
  170. $config['debug']['log'] = array('type' => 'file');
  171. }
  172. */
  173. $host = 'http://'.$local . '/';
  174. $upload = $host . 'upload/';
  175. $uploadcdn = $host . 'upload/data/';
  176. $config['host'] = array
  177. (
  178. 'upload'=> $upload . 'upload/?save',
  179. 'uploadRes' => isset($dc['res']) && $dc['res'] ? $dc['res'] : $uploadcdn . 'upload/',
  180. 'project' => array
  181. (
  182. 'upload' => array
  183. (
  184. 'path' => $host. 'upload/upload/?',
  185. ),
  186. 'pay' => array
  187. (
  188. 'path' => $host. 'pay/pay/?',
  189. ),
  190. 'wechat_applet' => array
  191. (
  192. 'path' => $host. 'wechat/wechat_applet/?',
  193. ),
  194. ),
  195. );
  196. return $config;