Web app that captures data and measures for the COR strategic plan
Note: This link won't work outside the internal oaktree network
- Heroku: Open
- Clone this repository on your local environment.
- Run
bundle install
to get all gem dependencies and prepare your database by runningrake db:create db:migrate
. - Optionally, run
rake db:seed
to fill your db with fake seed data. - To run in a local dev server run
puma -C "-"
. Your application will now be accessible athttp://localhost:9292/
This application uses RSpec Rails, Guard, Shoulda matchers, and Factory Girl for testing.
- To prepare your test database after first cloning/forking this repository run
rake db:test:prepare
- To run all tests one time simple run
rspec
orbundle exec rspec
if you don't have the gem installed globally - To watch for changes in spec files or app files and re-run your test suite each time run
guard
orbundle exec guard
####Useful Red Hat commands:
Start Puma server: bundle exec puma -e production --daemon
Restart a running Puma server: pumactl restart
Restore pg dump: pg_restore --verbose --clean --no-acl --no-owner -h localhost -U user -d dbname latest.dump
Create a pg dump: pg_dump -Fc --no-acl --no-owner -h localhost -U strategicplanning strategic_planning_production > strategic_planning_production.dump
See which services are running: ps -ef | grep puma
Kill a running service: kill pid
Run a service on machine startup: chkconfig postgresql-9.5 on
Do something with a service: sudo service nginx restart
Check out RHEL version: cat /etc/redhat-release
Get number of CPU cores: grep -c processor /proc/cpuinfo
If system is broken and missing essential packages like service and chkconfig: sudo yum reinstall initscripts
and then export PATH=$PATH:/sbin
to add /sbin to execute those paths without the /sbin prefix
###Installing Latest Postgres:
####Uninstalling current pg:
- sudo yum erase postgresql postgresql-libs.x86_64 (or sudo yum remove postgresql postgresql-libs.x86_64)
- sudo yum clean all
- rm -rf /var/lib/pgsql/
####Installing most recent pg:
- sudo yum localinstall https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-6-x86_64/pgdg-redhat95-9.5-2.noarch.rpm
- sudo yum install postgresql95.x86_64 postgresql95-server.x86_64 postgresql95-devel.x86_64
####Initializing the db:
- sudo service postgresql-9.5 initdb
- sudo chkconfig postgresql-9.5 on
- sudo service postgresql-9.5 start
Note: May need to edit this file sudo vim /var/lib/pgsql/9.5/data/pg_hba.conf and change ident to trust or at least md-5
###Installing ROR on Red Hat Enterprise Linux Server release 6.7
####Installing Ruby (with RVM):
- gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
- \curl -sSL https://get.rvm.io | bash -s stable
- vim ~/.bash_profile
- Add source ~/.profile at the bottom
- Refresh your paths: source ~/.bash_profile
- rvm install ruby-2.3.0
- gem install bundler —no-doc
####Cleaning up Yum:
- sudo rm /etc/yum.repos.d/ruby_1.9.3.repo
- sudo vim /etc/yum.conf -> Replace $releasever with 6
- sudo yum upgrade
- sudo yum clean all
- Open up ~/.profile or ~/.bash_profile and append :/sbin to the $PATH. For example: export PATH="$PATH:$HOME/.rvm/bin:/sbin”
- Refresh your profile with source ~/.bash_profile
####Installing Nginx:
- sudo vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/rhel/6/$basearch/
gpgcheck=0
enabled=1
- sudo yum install nginx
- sudo service nginx start (If you get command service does not exist, look at steps 5 and 6 of cleaning up yum or try sudo yum reinstall initscripts before these steps)
- Verify it installed correctly by visiting your server URL (e.g. http://rorprdapp1.ci.raleigh.nc.us/)
- sudo chkconfig nginx on
- sudo vim /etc/nginx/conf.d/default.conf
Delete or comment out everything (note: there’s a closing bracket at the very end of the file). Paste the following:
upstream app {
# Path to Puma SOCK file, as defined previously
server unix:/home/CORALEIGH/username/repo-name/shared/sockets/puma.sock fail_timeout=0; # Path where web server (puma in this case) will be listening
}
server {
listen 80;
server_name localhost;
root /home/CORALEIGH/username/repo-name/public; # App root path
try_files $uri/index.html $uri @app;
location / {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Connection '';
proxy_pass http://app;
}
location ~ ^/(assets|fonts|system)/|favicon.ico|robots.txt {
gzip_static on;
expires max;
add_header Cache-Control public;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
- sudo service nginx restart
####Configuring Postgres
- Go through the installing latest postgres section if necessary
- sudo su - postgres
- createuser -s username
- exit
- psql -U username -h localhost -d postgres
- CREATE DATABASE db_name;
- \password
- \q
####Optional: Migrating an existing database from Heroku
- Wherever you have Heroku tool belt and remote installed run: heroku pg:backups capture
- heroku pg:backups public-url (copy this URL)
- On server run: cd ~/tmp
- curl -o latest.dump “paste that URL here”
- pg_restore --verbose --clean --no-acl --no-owner -h localhost -U username -d db_name latest.dump
####Pulling your RoR application (with Puma)
- cd ~
- git clone https://github.com/david-meza/strategic-planning-measures.git (Whatever you application repo web address is)
- cd app
- mkdir -p shared/pids shared/sockets shared/log
- bundle install (If you have troubles installing pg, try gem install pg -- --with-pg-config=/usr/pgsql-9.5/bin/pg_config)
- vim config/application.yml (paste your env variables)
- sudo yum install nodejs npm
- bundle exec rake assets:precompile
- RAILS_ENV=production bundle exec rake db:migrate
- bundle exec puma -e production --daemon