Clojure based implementation of RuuviTrackerServer.
See http://www.ruuvitracker.fi/ for more details.
Server works either with standalone servlet container (for example Jetty) or with Heroku cloud.
-
git: http://git-scm.com/
-
Leiningen: https://github.com/technomancy/leiningen
-
Use 2.0 version. Use 2.0.0-preview8 or later
-
With Linux, try
sudo apt-get install leiningen
orsudo yum install leiningen
. Most of the distributions will currently have old 1.x.x version of leiningen.
Currently server implements Tracker API and Client API partially.
- Requests are saved to database, but they are not properly validated yet.
- Fetch sources
git clone git://github.com/jsyrjala/ruuvitracker_server.git
- Setup database, see
src/resources/server-dev-config.clj
- Fetch dependencies
lein deps
- Create tables to database and populate database
lein run -m ruuvi-server.launcher migrate lein run -m ruuvi-server.launcher load-test-data
- Start server
lein ring server
- Access web application http://localhost:3001/api/v1-dev/events
- Get sources
git clone git://github.com/RuuviTracker/ruuvitracker_server.git
- Create Heroku account
- Simply create an Heroku account and push code to Heroku.
- Create heroku application
heroku create --stack cedar
- Add heroku as git remote
git remote add heroku git@heroku.com:APPNAME.git
- Configure heroku
heroku addons:add heroku-postgresql:dev
heroku config:add RUUVISERVER_ENV=heroku --app APPNAME
- Create tables to database and some content to tables
heroku run lein run -m ruuvi-server.launcher migrate heroku run lein run -m ruuvi-server.launcher load-test-data
- Start heroku process
heroku scale web=1
- Access the app http://APPNAME.herokuapp.com/api/v1-dev/events
Server uses PostgreSQL or H2 database engines. See resources/server-XXX-config.clj
files for database configuration.
Static html files are located in resources/public
. Add javascript ui there.
Travis is used as CI.
See http://travis-ci.org/#!/RuuviTracker/ruuvitracker_server
Production code lives under 'src', unit-tests and other automatic tests live under 'test'. Directory 'test-utils' contains scripts usable in manual testing. Directory 'resources' contains data files that are not executable code.
Unit tests are implemented with Midje.
- 'ruuvi_server/' contains main functionality of the server.
- 'launcher.clj' is the starting point. Handles configuration and starts up serveres.
- 'configuration.clj' contains functions to handle configuration data. It also contains atom that holds current configuration.
- 'core.clj' sets up basic REST routes for whole software.
- 'api.clj' is the main starting point for API.
- 'client_api.clj' contains implementation of client part of API. Clients (web browsers, mobile devices) can get location data via JSON api.
- 'tracker_api.clj' contains implementation of tracker API. Tracker device can send location and other data using JSON API.
- 'tracker_security.clj' implements security features used in tracker API. HMAC based message verification.
- 'util.clj' contains generic utility functions.
- 'parse.clj' contains input parsing functions.
- 'lobos/' contains database migration files (a.k.a database schema changes). Migrations are implemented with Lobos frameworks.
- 'ruuvi_server/database/' contains database access layer, scripts for initally populating the database with test data and connection pooling. Database access is implemented with Korma library.
- 'entities.clj' contains definitions for ORM entities.
- 'event_dao.clj' contains DAO functions for manipulating event data.
- 'pool.clj' constructs a connection pool.
Copyright (C) 2012 Juha Syrjälä
BSD License