This repository is deprecated. Current development happen in PTT.ai-next.
Official golang implementation of the PTT.ai Framework.
The architecture of PTT.ai can be found in the link (中文版)
More documents can be found in PIPs
go get github.com/ailabstw/go-pttai
go install github.com/ailabstw/go-pttai/cmd/gptt
${GOPATH}/bin/gptt
All License can be found in docs/
./scripts/docker_build.sh
./scripts/docker.sh
./scripts/docker_stop.sh
./scripts/docker_push.sh
./scripts/docker_with_storage.sh -p [http-port in local-machine] -a [api-port in local-machine] -q [p2p-port in local-machine] -e [optional external http/https addr] -b [optional external api addr] -s [dir]
make test
Testing for specific dir:
./scripts/test.sh [dir]
(ex: ./scripts/test.sh common)
Testing for specific e2e-test
./scripts/e2e.sh [any test in the e2e dir]
ex: ./scripts/e2e.sh friend_basic
./scripts/doc.sh
The code-structure is based on go-ethereum. The following is the general guide for the development.
go get github.com/ailabstw/go-pttai; cd ${GOPATH}/src/github.com/ailabstw/go-pttai; ./scripts/init_cookiecutter.sh; source __/bin/activate
./scripts/gptt-testnet.sh
- follow gofmt / goimports
- follow gotests
- coding style (in-general):
- Each struct file (generated from ./scripts/dev_struct.sh) represents 1 struct
- Each module file (generated from ./scripts/dev_module.sh) represents 1 public function
- Struct is always CapitalizedCamelCase
- Public constants / variables / functions / member variables / member functions are CapitalizedCamelCase
- local constants / variables / functions / member variables / member functions are lowerCamelCase
- Global variables are in globals.go
- Global test variables are in globals_test.go
- Errors are in errors.go
- Naming:
- Full name: PTTai, pttai, PTT.ai
- cmd: gptt, Gptt (go-ptt)
- Default ports:
- http-connection: 9774
- api-connection: 14779
- p2p-connection: 9487
- ssh -L [rpcport-for-localhost]:localhost:[rpcport-for-remote-host] [username]@[remote-host]
- ssh -L [httpport-for-localhost]:localhost:[httpport-for-remote-host] [username]@[remote-host]
- ./build/bin/gptt --testwebrtc --rpcport [port-for-remote-host] --httpaddr 127.0.0.1:[http-port] --exthttpaddr http://localhost:[httpport-for-localhost] --extrpcaddr http://localhost:[rpcport-for-localhost]
- (in browser) http://localhost:[httpport-for-localhost]
-
Create Linode with Stackscript ID: 399252 (hsiaochuanheng / p.me-docker (go-pttai))
-
Launch the console and ensure that the new linode is created successfully.
-
ssh -L 14779:localhost:14779 admin@[IP]
-
ssh -L 9774:localhost:9774 admin@[IP]
-
open browser and connect to http://localhost:9774
-
Update (in admin@[IP]):
sudo -s docker pull ailabstw/go-pttai:latest HTTPPORT=9774 APIPORT=14779 docker run -e HTTPPORT=${HTTPPORT} -e APIPORT=${APIPORT} -itd --restart=always -p 9487:9487 -p 127.0.0.1:9774:9774 -p 127.0.0.1:14779:14779 -v /home/admin/pttai.docker:/root/.pttai --name go-pttai ailabstw/go-pttai:latest gptt "--testwebrtc" "--httpdir" "/static" "--httpaddr" "0.0.0.0:9774" "--rpcaddr" "0.0.0.0" "--exthttpaddr" "http://localhost:${HTTPPORT}" "--extrpcaddr" "http://localhost:${APIPORT}"
-
Create docker-with-ubuntu in One-click Applications.
-
Install / Update (in root@[IP]):
sudo -s docker pull ailabstw/go-pttai:latest HTTPPORT=9774 APIPORT=14779 docker run -e HTTPPORT=${HTTPPORT} -e APIPORT=${APIPORT} -itd --restart=always -p 9487:9487 -p 127.0.0.1:9774:9774 -p 127.0.0.1:14779:14779 -v /home/admin/pttai.docker:/root/.pttai --name go-pttai ailabstw/go-pttai:latest gptt "--testwebrtc" "--httpdir" "/static" "--httpaddr" "0.0.0.0:9774" "--rpcaddr" "0.0.0.0" "--exthttpaddr" "http://localhost:${HTTPPORT}" "--extrpcaddr" "http://localhost:${APIPORT}"
-
ssh -L 14779:localhost:14779 root@[IP]
-
ssh -L 9774:localhost:9774 root@[IP]
-
open browser and connect to http://localhost:9774
-
Setup Key Pair in AWS ec2 console. (for SSH use)
-
Setup Security Group in AWS ec2 console
- Be sure to have port 22, 9487, 9774, 14779 open to 0.0.0.0/0
-
Create an ECS cluster with the correpsonding Key Pair and Security Group.
-
Install / Update (in ec2-user@[IP]):
sudo -s docker pull ailabstw/go-pttai:latest HTTPPORT=9774 APIPORT=14779 docker run -e HTTPPORT=${HTTPPORT} -e APIPORT=${APIPORT} -itd --restart=always -p 9487:9487 -p 127.0.0.1:9774:9774 -p 127.0.0.1:14779:14779 -v /home/admin/pttai.docker:/root/.pttai --name go-pttai ailabstw/go-pttai:latest gptt "--testwebrtc" "--httpdir" "/static" "--httpaddr" "0.0.0.0:9774" "--rpcaddr" "0.0.0.0" "--exthttpaddr" "http://localhost:${HTTPPORT}" "--extrpcaddr" "http://localhost:${APIPORT}"
-
ssh -L 14779:localhost:14779 ec2-user@[IP]
-
ssh -L 9774:localhost:9774 ec2-user@[IP]
-
open browser and connect to http://localhost:9774
-
Setup Key Pair in AWS ec2 console. (for SSH use)
Please remeber where you save the private key in your computer, you will need it at the last step.
-
This will deploy the pre-build p.me docker image for you
-
Click choice option
Upload your code
(Note: the code is already uploaded for you, you only have to click this option. This seems to be a bug of AWS.)
-
Click button
Review and Launch
-
Chose the key pair you just setup in
EC2 key pair
,thenSave
-
Click button
Create app
-
ssh -L 14779:localhost:14779 ec2-user@[IP]
-
ssh -L 9774:localhost:9774 ec2-user@[IP]
-
open browser and connect to http://localhost:9774