Giter Site home page Giter Site logo

congo's Introduction

Congo

GroupHub front-end. Allows brokers to help group admins and employees manage their benefit plans.

Getting started

  1. Make sure you have Git installed and the proper Github keys set up.
  2. Make sure you have a recent version of Ruby installed with the bundler gem.
  3. In order to run the tests, you will need Firefox installed. Visit https://www.mozilla.org/en-US/firefox/new/, download Firefox, copy it to your Applications folder, and run it once to make sure it's setup properly.
  4. Make sure you have Postgres installed. Run brew install postgresql and follow the instructions.
  5. Make sure you have Redis installed. Run brew install redis and follow the instructions.
  6. You will need ngrok in order to test enrollment locally. Visit http://ngrok.com and sign up. Under your Dashboard, make note of your "auth token". Then, in the Terminal, brew install ngrok, and run ngrok -authtoken YOUR_AUTH_TOKEN. Hit ctrl-c to quit.
  7. Clone the repo. git clone https://github.com/grouphub/congo.git.
  8. cd congo
  9. bundle
  10. Verify the settings in config/database.yml look correct.
  11. Run script/bootstrap.
  12. Run script/ngrok if you would like to receive callbacks from PokitDok.
  13. You can run the tests via bundle exec rspec spec.
  14. Run the server using script/start.
  15. Visit the site locally at http://localhost:5000.

Debugging

Debugging Ruby code

  1. Somewhere in your Ruby code, place a binding.remote_pry statement on its own line.
  2. Trigger that section of code.
  3. From your Terminal, run pry-remote. You will get a Ruby console whose context is the block containing your binding.remote_pry call.
  4. To exit, type exit and hit Enter.

Debugging JavaScript

  1. Open your developer console (in Firefox or Chrome, it is command-shift-i).
  2. In your JavaScript code, place a debugger statement on its own line.
  3. Refresh the page.
  4. Trigger that section of code.
  5. The window will go grey, and your console will be open to your line of code.
  6. To exit the debugger, click the icon that looks like a vertical bar followed by a "play" triangle.

Generate an ERD Diagram

brew install graphviz
bundle exec rake diagram:all
open doc/models_complete.svg

You can find the generated SVG files in doc/**/*.svg.

Deployment

Deploying to Heroku

  1. Login to http://heroku.com and make sure that your SSH keys are setup properly. Also make sure that you have access to "grouphub staging" project.
  2. Install the Heroku toolbelt and run heroku login to log in from the Terminal.
  3. Merge your code into master.
  4. git push heroku master

Deploying to Elastic Beanstalk

  1. brew install aws-elasticbeanstalk
  2. Follow instructions here to get setup.
  3. Merge your code into master.
  4. eb congo

Setting up Servers

Basic Setup

In order to SSH into servers, you will need to get the "grouphub-congo" keypair from Roger. Then you can shell in like so:

KEY=~/.ssh/grouphub-congo
HOST=ec2-52-1-31-195.compute-1.amazonaws.com
ssh -i $KEY ec2-user@$HOST

You will need to set the following environment variables in your ~/.bashrc or similar. You can get these keys from Roger.

export AWS_ACCESS_KEY_ID='...'
export AWS_SECRET_ACCESS_KEY='...'

Front-ends

Then you will need to install the Elastic Beanstalk tools.

brew install aws-elasticbeanstalk

To get setup, you will need to run the following:

eb init
eb use congo-staging

You can deploy like so:

eb deploy

To deploy to production:

eb use congo-production
eb deploy

Front ends are auto-scaled by Elastic Beanstalk and should not need to be provisioned manually. I will put more documentation here eventually.

To SSH into a front-end box:

# On your machine
eb ssh

# Once SSH'ed in
cd /var/app/current
bundle

# Run the Rails console
bundle exec rails console

# Run the Postgres console
PGPASSWORD=$RDS_PASSWORD bundle exec rails dbconsole

# Tail the logs
tail -n 50 -f log/production.log

# To sweep the database, first log into the AWS console, reboot RDS, then
script/bootstrap

Workers

Provisioning a New Server

Setup an EC2 instance using the control panel or the CLI tool. Use an "Amazon Linux" 64-bit AMI.

Make sure you can shell into the server. For example:

KEY=~/.ssh/grouphub-congo
HOST=ec2-52-1-31-195.compute-1.amazonaws.com
ssh -i $KEY ec2-user@$HOST

Prepare the server. Make sure you're ssh'ed in, and run:

# Install packages as root
sudo su
yum update --assumeyes
yum install --assumeyes \
  gcc-c++ patch readline readline-devel zlib zlib-devel \
  libyaml-devel libffi-devel openssl-devel make \
  bzip2 autoconf automake libtool bison iconv-devel \
  git tmux postgresql-libs postgresql-devel

curl -sL https://rpm.nodesource.com/setup | bash -
yum install --assumeyes nodejs
exit

# Consider running the following commands in `tmux`...

# Install rbenv, ruby, and bundler as ec2-user
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
source ~/.bashrc
rbenv install 2.2.0
rbenv global 2.2.0
mv ~/bin ~/bin.old
gem install bundler
rbenv rehash

Test that everything is correct:

which ruby # ~/.rbenv/shims/ruby
which bundle # ~/.rbenv/shims/bundle
bundle -v # Bundler version 1.9.1

Set the environment variables. Make sure you're SSH'ed in, fill in the following lines with your variables, then run:

echo '' >> ~/.bashrc
echo '# Environment variables' >> ~/.bashrc
echo 'export RACK_ENV="production"' >> ~/.bashrc
echo 'export SECRET_TOKEN="..."' >> ~/.bashrc
echo 'export SECRET_KEY_BASE="..."' >> ~/.bashrc
echo 'export AWS_ACCESS_KEY_ID="..."' >> ~/.bashrc
echo 'export AWS_SECRET_ACCESS_KEY="..."' >> ~/.bashrc
echo 'export AWS_ACCESS_KEY=$AWS_ACCESS_KEY_ID' >> ~/.bashrc
echo 'export AWS_SECRET_KEY=$AWS_SECRET_ACCESS_KEY' >> ~/.bashrc
echo 'export AWS_REGION="..."' >> ~/.bashrc
echo 'export RDS_HOSTNAME="..."' >> ~/.bashrc
echo 'export RDS_PORT="..."' >> ~/.bashrc
echo 'export RDS_DB_NAME="..."' >> ~/.bashrc
echo 'export RDS_USERNAME="..."' >> ~/.bashrc
echo 'export RDS_PASSWORD="..."' >> ~/.bashrc
echo 'export S3_BUCKET="..."' >> ~/.bashrc
echo 'export SQS_DEFAULT_QUEUE="..."' >> ~/.bashrc
echo 'export SQS_MAILERS_QUEUE="..."' >> ~/.bashrc
echo 'export REDIS_URL="..."' >> ~/.bashrc
echo 'export CONGO_CLOCK_SECONDS=300' >> ~/.bashrc
echo 'export CONGO_CLOCK_LOG=log/clock.log' >> ~/.bashrc
echo 'export CONGO_CLOCK_PID=tmp/pids/clock.pid' >> ~/.bashrc
echo 'export POKITDOK_CLIENT_ID="..."' >> ~/.bashrc
echo 'export POKITDOK_CLIENT_SECRET="..."' >> ~/.bashrc
echo 'export POKITDOK_CALLBACK_HOST="..."' >> ~/.bashrc
echo 'export SENDGRID_USERNAME="..."' >> ~/.bashrc
echo 'export SENDGRID_PASSWORD="..."' >> ~/.bashrc
echo 'export PAPERTRAIL_HOST="..."' >> ~/.bashrc
echo 'export PAPERTRAIL_PORT="..."' >> ~/.bashrc
echo 'export PAPERTRAIL_PROGRAM="..."' >> ~/.bashrc
echo 'export NEWRELIC_LICENSE_KEY="..."' >> ~/.bashrc
echo 'export NEWRELIC_APP_NAME="..."' >> ~/.bashrc

Make sure you have SQS, Postgres on RDS, and Redis on Elasticache setup and permissioned properly.

Test that everything is correct:

cat ~/.bashrc
env

In the Congo project on your local machine, edit "config/workers.rb" so that the "boxes" list also contains your new server's info.

Then try deploying:

WORKER_NAME=congo-staging-worker-1 bundle exec rake workers:deploy

Tasks

At any time you can get a full list of rake tasks:

# Show all rake tasks with descriptions
bundle exec rake -T

# Show all rake tasks
bundle exec rake -vT

# Show all worker-related tasks
bundle exec rake -T | grep workers

To get a list of servers:

bundle exec rake workers:info

To deploy all:

# Deploy all
bundle exec rake workers:deploy

# Deploy one
WORKER_NAME=congo-staging-worker-1 bundle exec rake workers:deploy

To stop or start the workers and clocks:

# Stop all
bundle exec rake workers:stop

# Stop one
WORKER_NAME=congo-staging-worker-1 bundle exec rake workers:stop

# Start all
bundle exec rake workers:start

# Start one
WORKER_NAME=congo-staging-worker-1 bundle exec rake workers:start

bundle exec rake workers:start and bundle exec rake workers:restart are synonyms. Both of them will try and stop the workers before starting them again.

congo's People

Contributors

allenbyerly avatar thenaox avatar ianrosedev avatar sventech avatar

Watchers

James Cloos avatar  avatar Joel S. avatar  avatar

congo's Issues

Populate "properties" forms

See /app/assets/data/*.json

Right now, it only supports text inputs. Please make a note of what field types or other customizations we need and I will add them.

Auto set the account upon login

A default account should be selected on login... the way it is now is confusing for a new user. When you login for the first time you should be presented with the account you would expect... so I suggest

Auto-set the account for each user upon login in the following order:

Admin account
Broker account
Group Admin Account
Member Account

So a member with no other account types will see the controls for their 1st member account.

A Broker that doesn't have admin account will see broker account controls

Admins with all account types will see admin controls upon login

Fix layout on mobile

When the user visits the site on an iOS device, the sidebar and navbar scroll instead of the main content area.

Activities

  • subject_type
  • subject_id
  • object_type
  • object_id
  • properties_data
  • Anything else?
  • Make sure the solution can be easily encrypted with PuzzleBox later

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.