jbcool17 / weatherstation

Rails Application used to collect data and manage arduino based weather sensors | User: admin Pass: test
https://jbweatherstation.herokuapp.com/
1 stars 0 forks source link

WeatherStation - README

Development Setup / Get Started

# Setup .env file
# http://www.openweathermap.org
WEATHER_API_KEY=XXXXX

# Setup free airbrake account
AIRBRAKE_PROJECT_ID=XXXX
AIRBRAKE_PROJECT_KEY=xxxxx

# EMAIL -
EMAIL=email@email.com

# Install Gems
$ bundle install

# Install JS Libs
$ yarn install

# Setup DB & Test Data
$ rake db:migrate
$ rake db:seed

# Start Dev Sensor Simulation
# This will make weather data posts to development
$ rake auto_sensor:start

Notes

API Example

curl -X POST -H "Content-Type: application/json" \
  -H "Cache-Control: no-cache" \
  -H "Authorization: Token token=<API-KEY>" \
  -d '{ "weather_datum": {"temp": 81.0, "humidity": 30.0" }}' \
  "http://localhost:3000/v1/weather_data"

=> {"status":"Record was created!","notification":true}

Specs

Frontend

Database

Whenever Gem/Cron Jobs

Deploy

# Deploy to Production
# Config capistrano
$ bundle exec cap production deploy

# to create more admin users on production
$ bundle exec cap production rails console

Heroku

heroku create OR heroku git:remote -a <name>

# Add NodeJS first, then ruby - This will get yarn working
$ heroku buildpacks:add heroku/nodejs
$ heroku buildpacks:add heroku/ruby

# Set ENV VARS
$ heroku config:set VAR=xxxx

# Deploy
$ git push heroku master

# Setup Database
$ heroku run rake db:migrate
$ heroku run rake db:seed

# db:seed creates a test admin user, but for security reasons users can only be created via:
$ heroku run rails console

# set up Heroku Scheduler to run:
$ rake outside_weather:current