instruments

command module
v0.0.0-...-23f5b10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2018 License: MIT Imports: 5 Imported by: 0

README

Prerequisites

You need to make sure your environment is setup up correctly:

  • go -- The Go Programming Language
  • dep -- Dependency management for Go
  • docker -- Build, Ship, and Run Any App, Anywhere

Get the sources

Clone the Git repository:

git clone https://github.com/picobank/instruments.git
cd instruments

Preparing the development environment

MacOSX

go get -u github.com/golang/dep/cmd/dep

Docker

Start the development environment:

docker-compose up -d

The app container is bundled with:

  • dep -- dependency manager
  • beego -- application framework
  • goose -- database migration tool

Running the development environment

Run dep ensure to make sure vendor/ is in the correct state.

To regenerate SQLBoiler models:

go generate

To test the generated code:

go test -v ./models/ -args -test.config=../database/sqlboiler.toml

MacOSX

TODO

## Docker

docker-compose exec app dep ensure

Run goose to initialize the instruments schema:

docker-compose exec app goose -dir database/migrations postgres "postgres://instruments:raspberry@db:5432/picobank?sslmode=disable" up

Run the application in development mode:

docker-compose exec app go run main.go

Connect to http://localhost:8080/v1/instruments

Stop the development environment:

docker-compose down

Prepare the Raspberry PI

Copy SQL scripts to the Raspberry PI:

scp database/initdb/*.sql pi@raspberrypi.local:~

Connect to the Raspberry PI:

ssh pi@raspberrypi.local

Install Postgres on Rasbian:

sudo apt install -y postgresql libpq-dev postgresql-client postgresql-client-common

Create the database and the schema:

sudo -u postgres psql -f database.sql
sudo -u postgres psql -f schema.sql

Enable remote access to the PostgreSQL instance:

sudo sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/" /etc/postgresql/9.6/main/postgresql.conf
cat << EOF | sudo tee -a /etc/postgresql/9.6/main/pg_hba.conf
host    picobank        instruments     0.0.0.0/0               md5
host    picobank        instruments     ::/0                    md5
EOF
sudo service postgresql restart

Build for and deploy on Raspberry PI

Run goose to initialize the instruments schema:

docker-compose exec app goose -dir database/migrations postgres "postgres://instruments:raspberry@raspberrypi.local:5432/picobank?sslmode=disable" up

Package the application:

docker-compose exec -e GOOS=linux -e GOARCH=arm -e GOARM=5 app bee pack

Copy the instruments.tar.gz file to the Raspberry and untar:

scp instruments.tar.gz pi@raspberrypi.local:~
ssh pi@raspberrypi.local
sudo tar xzvf instruments.tar.gz

Run the application in production mode:

sudo BEEGO_RUNMODE=prod DB_USER=instruments DB_PASSWORD=raspberry DB_HOST=localhost DB_NAME=picobank ./instruments

Connect to http://raspberrypi.local:8080/v1/instruments

Load testing (WIP)

$GATLING_HOME/bin/gatling.sh  -sf loadtests/simulations/ -bdf loadtests/bodies/ -df loadtests/data -m

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Contains all HTTP controllers
Contains all HTTP controllers

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL