Skip to content

Build and Install

iczc edited this page Jul 31, 2019 · 2 revisions

1 Requirements

  • Go version 1.8 or higher, with $GOPATH set to your preferred directory

2 Installation

Ensure Go with the supported version is installed properly:

$ go version
$ go env GOROOT GOPATH

Get the source code

$ git clone https://github.com/Bytom/vapor.git $GOPATH/src/github.com/vapor

Build

$ cd $GOPATH/src/github.com/vapor
$ make install

When successfully building the project, the vapord and vaporcli binary should be present in $GOPATH/bin/vapord and $GOPATH/bin/vaporcli directory, respectively.

3.1 Run Directly

Firstly, you need initialize node:

$ vapord init --chain_id=<chainID> --home <vapor-data-path>

There are three options for the flag --chain_id:

  • mainnet: connect to the mainnet.
  • testnet: connect to the testnet.
  • solonet: standalone mode.

For example, you can connect to the mainnet and store vapor data in $HOME/bytom/vapor:

$ vapord init --chain_id=mainnet --home $HOME/bytom/vapor

Then, start your node:

$ vapord node

available flags for vapord node:

    --auth.disable                     Disable rpc access authenticate
    --log_file string                  Log output file (default "log")
    --log_level string                 Select log level
    --p2p.dial_timeout int             Set dial timeout (default 3)
    --p2p.handshake_timeout int        Set handshake timeout (default 30)
    --p2p.keep_dial string             Peers addresses try keeping connecting to, separated by ','
    --p2p.laddr string                 Node listen address
    --p2p.lan_discoverable             Whether the node can be discovered by nodes in the LAN (default true)
    --p2p.max_num_peers int            Set max num peers (default 20)
    --p2p.proxy_address string         Connect via SOCKS5 proxy
    --p2p.proxy_password string        Password for proxy server
    --p2p.proxy_username string        Username for proxy server
    --p2p.seeds string                 Comma delimited host:port seed nodes
    --p2p.skip_upnp                    Skip UPNP configuration
    --prof_laddr string                Use http to profile vapord programs
    --vault_mode                       Run in the offline enviroment
    --wallet.disable                   Disable wallet
    --wallet.rescan                    Rescan wallet
    --wallet.txindex                   Save global tx index
    --web.closed                       Lanch web browser or not
    --ws.max_num_concurrent_reqs int   Max number of concurrent websocket requests that may be processed concurrently (default 20)
    --ws.max_num_websockets int        Max number of websocket connections (default 25)     

3.2 Running in Docker

3.2.1 Build the image

$ cd $GOPATH/src/github.com/vapor
$ docker build -t vapor .

3.2.2 Enter the iterative mode

$ docker run -it --net=host -v <vapor/data/directory/on/host/machine>:/root/.vapor vapor:latest

vapor data directory has three config files:

  • config.toml
  • federation.json
  • node_key.txt

Use exit to exit Docker's iterative mode.

3.2.3 Daemon mode

For example,

$ docker run -d --net=host -v <vapor/data/directory/on/host/machine>:/root/.vapor vapor:latest vapord node --web.closed --auth.disable

To list the running containers and check their container id, image, corresponding command, created time, status, name and ports being used:

$ docker container ls

or

$ docker ps

To execute a command inside a container, for example:

$ docker exec -it <containerId> vaporcli create-access-token <tokenId>

To stop a running container:

$ docker stop <containerId>

To remove a container:

$ docker rm <containerId>