1.3. 配置 Bigfile
Github: github.com/bigfile/bigfile
本节主要讲解如何配置 Bigfile
,基本上是零配置。由于 Bigfile
唯一的运行要求是 MySQ
L,所以只要配置了 MySQL
的连接信息就可以了。
默认配置
Bigfile
有一套自己的默认配置,如果您没有什么特殊的要求,基本不用指定,默认配置如下:
database:
driver: mysql
host: localhost
user: root
password: root
port: 3306
dbName: bigfile
log:
console:
enable: true
level: info
format: '%{color:bold}[%{time:2006/01/02 15:04:05.000}] %{pid} %{level:.5s} %{color:reset} %{message}'
file:
enable: true
path: storage/logs/bigfile.log
level: warn
format: '[%{time:2006/01/02 15:04:05.000}] %{pid} %{longfile} %{longfunc} %{callpath} ▶ %{level:.4s} %{message}'
maxBytesPerFile: 52428800
http:
apiPrefix: /api/bigfile
accessLogFile: storage/logs/bigfile.http.access.log
limitRateByIPEnable: false
limitRateByIPInterval: 1000
limitRateByIPMaxNum: 100
corsEnable: false
corsAllowOrigins:
- '*'
corsAllowMethods:
- PUT
- PATCH
- DELETE
corsAllowHeaders:
- Origin
corsExposeHeaders:
- 'Content-Length'
corsAllowCredentials: true
corsAllowAllOrigins: false
corsMaxAge: 3600
chunk:
rootPath: storage/chunks
命令行配置
如果您只是想配置数据库连接,我们提供了通过命令行配置的入口:
可以这样使用:
bigfile --db-host 192.168.0.104 --db-name bigfile_tesg ftp:start --tls-enable --cert-file server.pem --key-file server.key
配置文件加载顺序
如果您没有提供配置文件,那么就会使用默认的配置或者命令行指定的配置。那么如果当您指定了配置文件,配置应该放在哪里呢?
可以直接通过 --config
参数指定配置文件的位置,或者正如您在帮助信息中看到的,bigfile
将会在当前目录,用户主目录以及 /etc/bigfile
目录下寻找名为 .bigfile.yaml
的配置文件。
英文文档:bigfile.site
推荐文章: