Battery Historian工具安装(Mac OS)

2,013 阅读1分钟

根据Battery Historian安装指南安装Battery Historian工具

1.安装

有两种途径安装

1.1 通过Docker拉取镜像安装

打开Terminal运行命令

docker -- run -p 9999:9999 gcr.io/android-battery-historian/stable:3.0 --port 9999

但是,报错

Unable to find image 'gcr.io/android-battery-historian/stable:3.0' locally docker: Error response from daemon: Get https://gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).

换了一个镜像源就可以了

docker run -d -p 9999:9999 bhaavan/battery-historian

访问地址http://localhost:9999/

截屏2021-05-17 下午5.21.55.png

1.2 通过拉取源码运行

1.2.1 安装GoLang

通过Homebrew安装Go

$ brew install go

安装成功后,查看go版本

$ go version
go version go1.15.6 darwin/amd64

配置环境变量,go的安装路径在/usr/local/Cellar/go/

$ vim ~/.bash_profile
#GO
#GOROOT
export GOROOT=/usr/local/Cellar/go/1.15.6/libexec
#GOPATH
export GOPATH=/Users/slatte/development/go_project
#BIN
export PATH=$PATH:$GOPATH/bin

使配置生效

source ~/.bash_profile

1.2.2 下载battery-historian

$ go get -d -u github.com/google/battery-historian/...

1.2.2 运行go脚本

$  cd $GOPATH/src/github.com/google/battery-historian
$ go run setup.go
#运行(默认端口是9999)
$ go run cmd/battery-historian/battery-historian.go

访问地址http://localhost:9999/