Landslide is a small service used for the ElectionLand project that aggregated multiple reporting sources into a single feed for ElectionLand reporters to review.
Overall, Landslide is not useful outside of the Electionland project; it is provided for transparency sake.
- Install NodeJS
- On Mac:
brew install node
- On Mac:
- Install MongoDB
- On Mac:
brew install mongo
- On Mac:
- Run Mongo:
mongod --config /usr/local/etc/mongod.conf
- On Mac:
brew services start mongodb
- On Mac:
- Create database; use
mongo
to open mongo shell.use electionland
- Get code:
git clone ... && cd landslide
- Install dependencies:
npm install
- See Configuration
- Run application with:
node index.js
- For development, turn on all debugging:
DEBUG=* node index.js
- For development, turn on all debugging:
- Run scheduling task with:
node scheduler.js
The following steps were taken to deploy on Heroku
- Install Heroku command line tools.
- Create app:
heroku apps:create landslide
- MongoLab DB (set type as needed):
heroku addons:create mongolab:shared-cluster-2
- Set configuration for the application like
heroku config:set SLACK_CLIENT_ID=XXXX
. See configuration below for all options. - Push code:
git push heroku master
- Scale web (as needed):
heroku ps:scale web=1:performance-m
- Scale clock/scheduler (as needed):
heroku ps:scale clock=1:standard-1x
These are optional but helpful for election day.
- To be able to scale horizontally, the session handling and caching needs to be centralized. Use Redis.
- Heroku add-on:
heroku addons:create heroku-redis:premium-2
- Heroku add-on:
- New Relic for monitoring.
- Heroku add-on:
heroku addons:create newrelic:hawke
- Will need to set
NEW_RELIC_NO_CONFIG_FILE
totrue
andNEW_RELIC_APP_NAME
to whatever. Without these, the application will not load New Relic. See config instructions for more details.
- Heroku add-on:
- Papertrail for easier log viewing.
- Heroku add-on:
heroku addons:create papertrail:ludvig
- Heroku add-on:
- Load testing with Loader.io
- Heroku add-on:
heroku addons:create loaderio:basic
- Set
LOADERIO_VERIFY_TOKEN
to the host's verify token.
- Heroku add-on:
To actually run the application, you will need to configure certain things, specifically with application keys and secrets and the what not. These should be stored in environment variables, or in an .env
file.
SLACK_CLIENT_ID
SLACK_CLIENT_SECRET
SLACK_TEAM
SLACK_USERS_PRIVATE
: Comma-separated list of slack emails that can view private (Election Protection) data. For some reason, the basic identity information with Slack Sign-in doesn't provide username, hence the use of emails.MOBILE_COMMONS_USER
MOBILE_COMMONS_PASS
MOBILE_COMMONS_CAMPAIGN
SCREENDOOR_PROJECT
SCREENDOOR_KEY
ELECTION_PROTECTION_USER
ELECTION_PROTECTION_PASS
GOOGLE_API_KEY
SESSION_SECRET
HELLO_VOTE_KEY
: API key for incoming HelloVote data.FETCH_INTERVAL_SECONDS
: Number of seconds to wait in between fetches.FETCH_SINCE_MINUTES
: Number of minutes to look back with each fetch (after the first one), i.e. get data in the past hour.MONGODB_URI
: Should be something likemongodb://localhost:27017/electionland
or what is provided by the MonogoLab Heroku addon.NODE_ENV
: Set totest
and fake data will be put into the database, and the database name will be appended with-test
. Otherwise, usedevelopment
orproduction
.DEBUG
: Debug level via debug. For development,*
will debug all. For production, some level might be helpful such as:db,api,server,index,scheduler,data:*