Skip to content

Landslide is an aggregator of different ElectionLand sources for reporters involved with the project.

Notifications You must be signed in to change notification settings

datanews/landslide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Locally and development

  1. Install NodeJS
    • On Mac: brew install node
  2. Install MongoDB
    • On Mac: brew install mongo
  3. Run Mongo: mongod --config /usr/local/etc/mongod.conf
    • On Mac: brew services start mongodb
  4. Create database; use mongo to open mongo shell. use electionland
  5. Get code: git clone ... && cd landslide
  6. Install dependencies: npm install
  7. See Configuration

Commands

  • Run application with: node index.js
    • For development, turn on all debugging: DEBUG=* node index.js
  • Run scheduling task with: node scheduler.js

Heroku

The following steps were taken to deploy on Heroku

  1. Install Heroku command line tools.
  2. Create app: heroku apps:create landslide
  3. MongoLab DB (set type as needed): heroku addons:create mongolab:shared-cluster-2
  4. Set configuration for the application like heroku config:set SLACK_CLIENT_ID=XXXX. See configuration below for all options.
  5. Push code: git push heroku master
  6. Scale web (as needed): heroku ps:scale web=1:performance-m
  7. Scale clock/scheduler (as needed): heroku ps:scale clock=1:standard-1x

Services

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
  • New Relic for monitoring.
    • Heroku add-on: heroku addons:create newrelic:hawke
    • Will need to set NEW_RELIC_NO_CONFIG_FILE to true and NEW_RELIC_APP_NAME to whatever. Without these, the application will not load New Relic. See config instructions for more details.
  • Papertrail for easier log viewing.
    • Heroku add-on: heroku addons:create papertrail:ludvig
  • Load testing with Loader.io
    • Heroku add-on: heroku addons:create loaderio:basic
    • Set LOADERIO_VERIFY_TOKEN to the host's verify token.

Configuration

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 like mongodb://localhost:27017/electionland or what is provided by the MonogoLab Heroku addon.
  • NODE_ENV: Set to test and fake data will be put into the database, and the database name will be appended with -test. Otherwise, use development or production.
  • 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:*

About

Landslide is an aggregator of different ElectionLand sources for reporters involved with the project.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published