Grab messages from an AWS SQS queue, determine the action to take, generate message(s) and send them to Twilio.
- Docker
OR
- Golang 1.10
- A directory for Go development configured in $GOPATH, see below
- Godep
- go-bindata
- A .env file with the following items...
- The first three items in the example .env file below (AWS credentials and environment) MUST be in that order at the top of the file.
ACCESS_KEY_ID=
SECRET_ACCESS_KEY=
ENVIRONMENT=development
QUEUE_PREFIX=vip-sms-app
DB_PREFIX=vip-sms-app-users
CIVIC_API_KEY=
CIVIC_API_ELECTION_ID=
CIVIC_API_OFFICIAL_ONLY=true
TWILIO_SID=
TWILIO_TOKEN=
TWILIO_NUMBER=
PROCS=24
ROUTINES=4
LOGGLY_TOKEN=
NEWRELIC_TOKEN=
To set your system up to develop this application...
- Make sure you have everything from the requirements section
- If you do not have GOPATH configured, set one up pointing to a place you'll develop from. For example,
mkdir ~/dev/go
and thenexport GOPATH=~/dev/go
- Use godeps to get the dependencies and this repository:
godep get github.com/votinginfoproject/sms-worker
- This repo should now be at $GOPATH/src/github.com/votinginfoproject/sms-worker, cd into it.
- If you're using RBEnv to manage Ruby versions, make sure you have 2.1.2 installed and drop a .ruby-version file in this directory with the contents
2.1.2
to make sure you use the right version. - Run
bundle
If you're not on Linux and AMD64, you'll need to compile Go for Linux since the deploy artifact needs to be this as that's the kind of server it is installed on in AWS.
- Figure out where your Go install is:
which go
(/usr/local/bin/go if you installed with homebrew) - Find the go src path which should be nearby (/usr/local/Cellar/go/1.4.2/libexec/src if installed with homebrew)
- Make go for linux/AMD64 by running
GOOS=linux GOARCH=amd64 ./make.bash --no-clean
It is potentially easier to develop with Docker.
To compile and run the project, the typical docker build
and run
commands will work. When running, you will need to have the
environment variables above set, because the docker version does not
use the .env file.
With the environment variables set, the commands are:
$ docker build -t sms-worker .
$ docker run sms-worker
godep go test ./...
To run the tests in docker:
docker build -t sms-worker .
to build the Docker imagedocker run -ti --env-file .env sms-worker /bin/bash
to start the container with an interactive terminalgodep go test ./...
to run the tests.
go-bindata -prefix "data" -pkg "data" -o data/data.go data/raw
- Generates a new data/data.go file
See the sms-compose repository for deployment instructions.