LWS relies on a few other services to run (all services should be up before LWS which could connect to):
- MySQL Database
- Mqtt
- RabbitMQ
- Redis
- Core wallet
All these services could be configured in .env file (sample could be found in .env.sample).
Download binary from Github release page.
Or build the binary from repository by yourself:
GOOS=linux GOARCH=amd64 go build -o "./gateway" cmd/gateway/main.go
GOOS=linux GOARCH=amd64 go build -o "./stream" cmd/stream/main.go
GOOS and GOARCH could be specified by your target environment.
Then just start service by execute the binary files with environment variables in .env file.
Use go module (>= 1.11) to manage packages.
go mod download # download all dependenciesLWS requires MySQL, mqtt(mock server), RabbitMQ and redis as related services. In local development, we use Docker to manage them:
# where docker-compose.yml located
cd test/mock
# start services
docker-compose up -d
# stop services
docker-compose down# execute `./test/data/schema.sql`
# if you are using the docker-compose to set up mysql service
mysql --host=127.0.0.1 --port=13307 -u root lws < ./test/data/schema.sqlWe are using godotenv to manange variables in .env file (no required). To install the command-line tool:
go get github.com/joho/godotenv/cmd/godotenvThen in local development:
# run
godotenv go run path/to/main.go
# test
godotenv go test ./...In CI test, the environment variables should be configured in the CI panel.
In production, the environment variables should be used as normal env way or configured in CD panel.
Up:
go run cmd/db/migrate.goDown:
go run cmd/db/migrate.go -1