ATX ATX 安卓集群管理 atx-server 使用记录整理

老马 · 2018年06月20日 · 最后由 大大国 回复于 2018年12月05日 · 4665 次阅读

一 资源索引

官方网站:https://github.com/openatx/atx-server

参考帮助:https://testerhome.com/topics/11588

二 win 环境安装配置

Go 语言开发环境

https://golang.org/doc/install#install

两种方式 msi 安装包与绿色解压 zip 形式

我选择 msi,下载 go1.10.2.windows-amd64.msi 双击安装,安装目录 D:\Go\ 其他默认

检查安装相关:


C:\Users\cmd>go version

 go version go1.10.2 windows/amd64


C:\Users\cmd>go env

set GOARCH=amd64

set GOBIN=

set GOCACHE=C:\Users\cmd\AppData\Local\go-build

set GOEXE=.exe

set GOHOSTARCH=amd64

set GOHOSTOS=windows

set GOOS=windows

set GOPATH=C:\Users\cmd\go

set GORACE=

set GOROOT=D:\Go

set GOTMPDIR=

set GOTOOLDIR=D:\Go\pkg\tool\windows_amd64

set GCCGO=gccgo

set CC=gcc

set CXX=g++

set CGO_ENABLED=1

set CGO_CFLAGS=-g -O2

set CGO_CPPFLAGS=

set CGO_CXXFLAGS=-g -O2

set CGO_FFLAGS=-g -O2

set CGO_LDFLAGS=-g -O2

set PKG_CONFIG=pkg-config

set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\cmd\AppData\Local\Temp\go-build932373810=/tmp/go-build -gno-record-gcc-switches

rethinkdb 数据库环境

https://rethinkdb.com/docs/install/windows/
下载 rethinkdb-2.3.6.zip 解压到 D:\rethinkdb-2.3.6

安装和编译 atx-server

先检查下环境变量 GOPATH,会安装到该目录下 C:\Users\cmd\go


C:\Users\cmd>go env GOPATH

C:\Users\cmd\go

安装下载 atx-server

C:\Users\cmd>go get -v github.com/openatx/atx-server

github.com/openatx/atx-server (download)

github.com/codeskyblue/heartbeat (download)

github.com/codeskyblue/realip (download)

github.com/mattn/go-isatty (download)

github.com/openatx/androidutils (download)

github.com/openatx/androidutils/vendor/github.com/kballard/go-shellquote

github.com/mattn/go-isatty

github.com/openatx/atx-server/vendor/golang.org/x/crypto/pbkdf2

github.com/openatx/atx-server/vendor/golang.org/x/sys/windows

github.com/openatx/atx-server/vendor/github.com/alecthomas/template/parse

github.com/openatx/atx-server/vendor/github.com/alecthomas/units

github.com/openatx/atx-server/vendor/github.com/alecthomas/template

github.com/openatx/atx-server/vendor/golang.org/x/crypto/ssh/terminal

github.com/codeskyblue/heartbeat/vendor/github.com/pkg/errors

github.com/openatx/atx-server/vendor/github.com/hailocab/go-hostpool

github.com/openatx/atx-server/vendor/github.com/opentracing/opentracing-go/log

github.com/openatx/atx-server/vendor/golang.org/x/net/context

github.com/openatx/atx-server/vendor/github.com/sirupsen/logrus

github.com/openatx/androidutils

github.com/openatx/atx-server/vendor/gopkg.in/fatih/pool.v2

github.com/openatx/atx-server/vendor/github.com/cenkalti/backoff

github.com/openatx/atx-server/vendor/gopkg.in/gorethink/gorethink.v4/encoding

github.com/openatx/atx-server/vendor/github.com/golang/protobuf/proto

github.com/openatx/atx-server/vendor/github.com/alecthomas/kingpin

github.com/openatx/atx-server/vendor/gopkg.in/gorethink/gorethink.v4/types

github.com/openatx/atx-server/proto

github.com/openatx/atx-server/vendor/github.com/codeskyblue/inforus

github.com/openatx/atx-server/vendor/github.com/codeskyblue/dingrobot

github.com/codeskyblue/realip

github.com/openatx/atx-server/vendor/github.com/codeskyblue/realip

github.com/openatx/atx-server/vendor/github.com/gorilla/mux

github.com/openatx/atx-server/vendor/github.com/gorilla/websocket

github.com/openatx/atx-server/vendor/github.com/mash/go-accesslog

github.com/openatx/atx-server/vendor/github.com/opentracing/opentracing-go

github.com/codeskyblue/heartbeat

github.com/openatx/atx-server/vendor/gopkg.in/gorethink/gorethink.v4/ql2

github.com/openatx/atx-server/vendor/github.com/opentracing/opentracing-go/ext

github.com/openatx/atx-server/vendor/github.com/koding/websocketproxy

github.com/openatx/atx-server/vendor/gopkg.in/gorethink/gorethink.v4

github.com/openatx/atx-server


go build 编译 atx-server

C:\Users\cmd>cd %GOPATH%\src\github.com\openatx\atx-server

C:\Users\cmd\go\src\github.com\openatx\atx-server>go build

启动 rethinkdb 和 atx-server

启动 rethinkdb

D:\rethinkdb-2.3.6>rethinkdb --http-port 8090

In recursion: removing file 'D:\rethinkdb-2.3.6\rethinkdb_data\tmp'

warn: Trying to delete non-existent file 'D:\rethinkdb-2.3.6\rethinkdb_data\tmp'

Initializing directory D:\rethinkdb-2.3.6\rethinkdb_data

Running rethinkdb 2.3.6-windows (MSC 190024215)...

Running on 6.2.9200 (Windows 8, Server 2012)

Loading data from directory D:\rethinkdb-2.3.6\rethinkdb_data

Listening for intracluster connections on port 29015

Listening for client driver connections on port 28015

Listening for administrative HTTP connections on port 8090

Listening on cluster address: 127.0.0.1

Listening on driver address: 127.0.0.1

Listening on http address: 127.0.0.1

To fully expose RethinkDB on the network, bind to all addresses by running rethinkdb with the `--bind all` command line option.

Server ready, "cmd_g2r" b2d71fe8-cb99-417e-aec7-e3121f0aa1d4

启动 atx-server

C:\Users\cmd\go\src\github.com\openatx\atx-server>atx-server --port 8000

[36mINFO[0m[0000] initial database [36mfile[0m=hooks.go [36mline[0m=28

[36mINFO[0m[0002] found db: rethinkdb [36mfile[0m=hooks.go [36mline[0m=28

[36mINFO[0m[0002] found db: test [36mfile[0m=hooks.go [36mline[0m=28

[36mINFO[0m[0002] create tables [36mfile[0m=hooks.go [36mline[0m=28

[36mINFO[0m[0005] listen address:8000 [36mfile[0m=hooks.go [36mline[0m=28

virtualenv ATX364 下安装部署 atx 和 uiautomator2 相关

参考 win10 使用 virtualenv 创建基于 Python3.6.4 的 ATX364 python 虚拟环境

# 先安装好Python3 我安装了python-3.6.4-amd64.exe 到D:\Python36\目录下
#  然后安装 pip install virtualenv 即可
#创建win10 环境下的 python3.6.4  virtualenv ATX364

C:\Users\cmd>virtualenv -p D:\Python36\python3.exe ATX364
Running virtualenv with interpreter D:\Python36\python3.exe
Using base prefix 'D:\\Python36'
New python executable in C:\Users\cmd\ATX364\Scripts\python3.exe
Also creating executable in C:\Users\cmd\ATX364\Scripts\python.exe
Installing setuptools, pip, wheel...done.

# 切换到部署好的virtualenv ATX364环境
C:\Users\cmd>cd ATX364\Scripts

C:\Users\cmd\ATX364\Scripts>activate.bat
(ATX364) C:\Users\cmd\ATX364\Scripts>

#默认安装的py包
(ATX364) C:\Users\cmd\ATX364\Scripts>pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
pip (9.0.2)
setuptools (39.0.1)
wheel (0.30.0)
# 安装atx

(ATX364) C:\Users\cmd\ATX364\Scripts>pip install --upgrade --pre atx

 #安装opencv

(ATX364) C:\Users\cmd\ATX364\Scripts>pip install --upgrade opencv_contrib_python

 # 检查安装后atx版本

(ATX364) C:\Users\cmd\ATX364\Scripts>python -m atx version

1.2.1.dev5

 #atx doctor检查atx相关

(ATX364) C:\Users\cmd\ATX364\Scripts>python -m atx doctor

Android Debug Bridge version 1.0.39

Version 0.0.1-4500957

Installed as D:\Android\android-sdk-windows\platform-tools\adb.exe

[GOOD] adb found in env PATH

 # 安装atx的uiautomator2

(ATX364) C:\Users\cmd\ATX364\Scripts>pip install --pre --upgrade uiautomator2

向手机安装 atx 的 uiautomator2

确认 adb devices 可连通手机,手机需要开启开发者选项 usb 调试等相关

比如,真机小米 Mix2,需要开启真机开发者选项->USB 调试,模式和其他相关,主要是调试这一栏要打开的有:

哦,还有就是接上手机的时候,小米 Mix 会提示选择"USB 用途" (有 1 仅限充电 2 传输文件 MTP 3 传输照片 PTP) 你需要选择 传输文件 MTP 该项.否则 adb devices -l 会报一个类似权限未获取到的提示.

 C:\Users\cmd>adb devices -l
List of devices attached
yourSerialNo              device product:chiron model:MIX_2 device:chiron transport_id:14

确保启动的 atx-server 与被连接手机在同一 wifi 网络环境下

先用 ipconfig /all 查看当前 atx-server 机器所连 wifi ip ip(注意一定要用这个查到的 ip 向 usb 连接的手机真机初始化 也就是下边的 python -m uiautomator2 init ip:8000 这个 ip 和你 atx-server 的 ip 要是同一个 )

# 做好以上便可,向该usb连接的手机安装atx的uiautomator2

(ATX364) C:\Users\cmd\ATX364\Scripts>python -m uiautomator2 init ip:8000

2018-05-29 16:06:05,397 - __main__.py:254 - INFO - atx-server addr ip:8000

2018-05-29 16:06:05,492 - __main__.py:269 - INFO - Detect pluged devices: ['yourSerialNo']

2018-05-29 16:06:05,492 - __main__.py:286 - INFO - Device(yourSerialNo) initialing ...

2018-05-29 16:06:06,272 - __main__.py:113 - INFO - install minicap

2018-05-29 16:06:06,601 - __main__.py:120 - INFO - install minitouch

2018-05-29 16:06:07,283 - __main__.py:143 - INFO - app-uiautomator.apk(1.0.14) installing ...

2018-05-29 16:06:11,322 - __main__.py:148 - INFO - app-uiautomator-test.apk installing ...

2018-05-29 16:06:14,861 - __main__.py:175 - INFO - atx-agent(0.3.2) already installed, skip

2018-05-29 16:06:15,307 - __main__.py:212 - INFO - launch atx-agent daemon

2018-05-29 16:06:17,462 - __main__.py:228 - INFO - atx-agent output: server started, listening on 172.25.0.163:7912

2018-05-29 16:06:17,647 - __main__.py:232 - INFO - success

成功后即可访问:
http://localhost:8000/
http://ip:8000/ 均可
还需要关掉 atx-server 所启动机器的 360 或者 eset 等杀软,否则无法正常访问到该链接.

连接成功 atx-server 也会有响应连接上的日志

16:53:15] [0;m200 GET /version (172.**.*.***) 0.00ms
[36mINFO[0m[0143] 760ABLAAHPFU-38:bc:1a:22:50:95-MX4_Pro is online [36mfile[0m=hooks.go [36mline[0m=28
16:53:17] [0;m200 GET /list ([) 1029.24ms
16:53:19] [0;m200 GET /version (17.25.*.***) 0.00ms
16:53:19] [0;m200 GET /list ([) 8.01ms
[36mINFO[0m[0146] yourSerialNo-e4:46:da:52:2f:d2-MIX_2 is online [36mfile[0m=hooks.go [36mline[0m=28
[37mDEBU[0m[0153] ws read closed [37mfile[0m=hooks.go [37mline[0m=28
[37mDEBU[0m[0153] ws write closed [37mfile[0m=hooks.go [37mline[0m=28

安卓集群管理界面

远程使用界面

三 ubuntu 环境安装配置

与 win 类似

只有 rethinkdb 无法通过 apt repository 来安装 (官方还未支持更新 18.04 bionic Release),用了一个人打包的 18.04 bionic Release deb 包可以正常使用

安装过程记录

不详细展开说明了
安装 Golang go 语言开发环境和 rethinkdb:

安装 Golang 环境
下载地址:https://golang.org/dl/go1.10.2.linux-amd64.tar.gz

https://golang.org/doc/install?download=go1.10.2.linux-amd64.tar.gz
安装说明参考:
http://www.runoob.com/go/go-environment.html

# 我习惯安装到了/opt/目录下 
tar -C /opt -xzf go1.10.2.linux-amd64.tar.gz

# 配置编辑go环境变量,我习惯编辑到 ~/.profile
cmd@TR:~$ sudo gedit ~/.profile
#末尾追加
#Go Enviromnet Path
export GOROOT=/opt/go
export PATH=$PATH:$GOROOT/bin

#我的习惯不用root账号,解压完一般全部改为当前账号所属组和用户
cmd@TR:/opt$ sudo chown -R cmd:cmd go
[sudo] cmd 的密码: 
cmd@TR:/opt$ ls -al|grep go
drwxr-xr-x 11 cmd  cmd  4096 5月   1 04:34 go

# 检查go版本 
cmd@TR:~$ go version
go version go1.10.2 linux/amd64

安装好 rethinkdb:
安装说明参考
https://rethinkdb.com/docs/install/
https://rethinkdb.com/docs/install/ubuntu/

但该 apt repository 未支持 ubuntu18.04 bionic
Install RethinkDB on Ubuntu
Looking for another platform? See the complete list of platforms RethinkDB supports.
With binaries
We provide binaries for both 32-bit and 64-bit Ubuntu Precise and above (>= 12.04).
To install the server, you have to add the RethinkDB repository to your list of repositories and install via apt-get.
To do this, paste the following lines into your terminal:
source /etc/lsb-release && echo "deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
wget -qO- https://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install rethinkdb

参考该 issue 解决安装:
https://github.com/rethinkdb/rethinkdb/issues/6648
I put my bionic packages here: https://github.com/srh/rethinkdb/releases/tag/v2.3.6.srh.1
You can download the .deb and install it with dpkg -i filename.deb.

下载 rethinkdb_2.3.6.srh.1.0bionic_amd64.de 并安装
sudo dpkg -i rethinkdb_2.3.6.srh.1.0bionic_amd64.deb

cmd@TR:~$ go env GOPATH
/home/cmd/go

#安装下载atx-server 会默认到 GOPATH 指定的路径.
cmd@TR:~$ go get -v github.com/openatx/atx-server
github.com/openatx/atx-server (download)
created GOPATH=/home/cmd/go; see 'go help gopath'
github.com/codeskyblue/heartbeat (download)
github.com/codeskyblue/realip (download)
github.com/mattn/go-isatty (download)
github.com/openatx/androidutils (download)
github.com/openatx/androidutils/vendor/github.com/kballard/go-shellquote
github.com/openatx/atx-server/vendor/golang.org/x/crypto/pbkdf2
github.com/mattn/go-isatty
github.com/openatx/atx-server/vendor/golang.org/x/sys/unix
github.com/openatx/atx-server/vendor/github.com/alecthomas/template/parse
github.com/openatx/atx-server/vendor/github.com/alecthomas/units
github.com/codeskyblue/heartbeat/vendor/github.com/pkg/errors
github.com/openatx/atx-server/vendor/github.com/codeskyblue/dingrobot
github.com/codeskyblue/realip
github.com/openatx/atx-server/vendor/github.com/codeskyblue/realip
github.com/openatx/atx-server/vendor/github.com/gorilla/mux
github.com/openatx/atx-server/vendor/github.com/mash/go-accesslog
github.com/openatx/atx-server/vendor/github.com/gorilla/websocket
github.com/openatx/androidutils
github.com/openatx/atx-server/vendor/golang.org/x/net/context
github.com/codeskyblue/heartbeat
github.com/openatx/atx-server/proto
github.com/openatx/atx-server/vendor/github.com/hailocab/go-hostpool
github.com/openatx/atx-server/vendor/github.com/cenkalti/backoff
github.com/openatx/atx-server/vendor/github.com/opentracing/opentracing-go/log
github.com/openatx/atx-server/vendor/gopkg.in/fatih/pool.v2
github.com/openatx/atx-server/vendor/github.com/alecthomas/template
github.com/openatx/atx-server/vendor/gopkg.in/gorethink/gorethink.v4/encoding
github.com/openatx/atx-server/vendor/gopkg.in/gorethink/gorethink.v4/types
github.com/openatx/atx-server/vendor/github.com/golang/protobuf/proto
github.com/openatx/atx-server/vendor/golang.org/x/crypto/ssh/terminal
github.com/openatx/atx-server/vendor/github.com/opentracing/opentracing-go
github.com/openatx/atx-server/vendor/github.com/koding/websocketproxy
github.com/openatx/atx-server/vendor/github.com/opentracing/opentracing-go/ext
github.com/openatx/atx-server/vendor/github.com/sirupsen/logrus
github.com/openatx/atx-server/vendor/github.com/alecthomas/kingpin
github.com/openatx/atx-server/vendor/github.com/codeskyblue/inforus
github.com/openatx/atx-server/vendor/gopkg.in/gorethink/gorethink.v4/ql2
github.com/openatx/atx-server/vendor/gopkg.in/gorethink/gorethink.v4
github.com/openatx/atx-server


#go build编译atx-server 
cmd@TR:~$ cd go/src/github.com/openatx/atx-server/
cmd@TR:~/go/src/github.com/openatx/atx-server$ go build


#启动rethinkdb 
cmd@TR:~$ rethinkdb --http-port 8090
Recursively removing directory /home/cmd/rethinkdb_data/tmp
Initializing directory /home/cmd/rethinkdb_data
Running rethinkdb 2.3.6.srh.1~0bionic (CLANG 6.0.0 (tags/RELEASE_600/final))...
Running on Linux 4.15.0-23-generic x86_64
Loading data from directory /home/cmd/rethinkdb_data
Listening for intracluster connections on port 29015
Listening for client driver connections on port 28015
Listening for administrative HTTP connections on port 8090
Listening on cluster addresses: 127.0.0.1, ::1
Listening on driver addresses: 127.0.0.1, ::1
Listening on http addresses: 127.0.0.1, ::1
To fully expose RethinkDB on the network, bind to all addresses by running rethinkdb with the `--bind all` command line option.
Server ready, "TR_yo7" 18191f63-1cee-4a20-a335-083e351b893b


#启动atx-server 
cmd@TR:~$ cd go/src/github.com/openatx/atx-server/
cmd@TR:~/go/src/github.com/openatx/atx-server$ atx-server --port 8000
INFO[0000] initial database                              file=hooks.go line=28
INFO[0000] found db: rethinkdb                           file=hooks.go line=28
INFO[0000] found db: test                                file=hooks.go line=28
INFO[0000] create tables                                 file=hooks.go line=28
INFO[0003] listen address:8000                           file=hooks.go line=28

以下同 win 请参考以上 win 相关内容

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 8 条回复 时间 点赞

不是很懂为什么要创建一个 virtualenv ATX364,直接执行下一步也是 OK 的?!

Joe 回复

所有的 py 包 比如 atx 的 和 appium 的 或者 macaca 的 放一个 py3 环境里 会乱掉的. 同样的方法或类名 在 pycharm 里分不清谁是谁的.
所以 隔离单独给 ATX 弄个虚拟环境,方便调试 atx 相关类和方法.

老马 回复

别人没你这个么折腾 不用 virtualenv 也 ok

老马 回复

Ok,受教了~

win7 安装 atx 报错如下:

F:\Go\src>go get -v github.com/openatx/atx-server
github.com/openatx/atx-server (download)

cd .; git clone https://github.com/openatx/atx-server F:\golang\go\src\github.

com\openatx\atx-server
Cloning into 'F:\golang\go\src\github.com\openatx\atx-server'...
fatal: unable to access 'https://github.com/openatx/atx-server/:' error:1407742E
:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
package github.com/openatx/atx-server: exit status 128

docker 方案已经在路上

仅楼主可见

小米 4,安装时一闪而过,咋弄?

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册