Play 2 Starter Project
(currently in development)
This project is meant to get the ball rolling on new projects. It is built upon Play 2 and the backend uses Google Guice extensively for dependency injection. It also has integrated support for Yammer Metrics allowing you to easily annotate your API endpoints and other methods to receive metering/timing information, as well as set up health checks (e.g. connections to databases, etc). To better view this information, it currently comes with an administrative console (heroku demo here, if I haven't broken it while developing). The metrics data is pushed to Redis on a regular interval from each node, but could be set up to push to other sources (e.g. MongoDB). The admin dashboard is written using AngularJS, RequireJS, and Twitter Bootstrap.
Documentation will come later, don't get your hopes up too soon on that front -- but good code "documents itself," or so people who never write documentation tell me.
- Install Play 2
- Install Redis by the means most appropriate for your OS (e.g. Homebrew on Mac)
- Clone this project to your favorite directory
- Launch the Redis server (most likely by running
redis-serveron the command line) and leave it running
- From the root of the project directory where you cloned the code, launch
play runto start the application in DEVELOPMENT mode
From here you can navigate your browser to localhost at the /admin endpoint (e.g.
http://localhost:9000/admin) to view the dashboard. You may need to wait a few seconds and refresh your browser for metric data to come in, as it is only synced every 5 seconds.
A few notes about deployment:
- You should change the
conf/production.jsonconfiguration file to match your environment
- The minified/processed files for the dashboard are currently checked in. They are the result of running
play optimizejs(combo/minifying using the RequireJS optimizer, currently requires NodeJS to be installed) and will need to be re-run after any front-end changes. The reason for this has more to do with me targeting Heroku at the moment than a necessity. Heroku executes certain build steps after a git push, and having this hooked into the build (which required I use the Java Rhino implementation of JS, rather than being able to use Node since Node isn't in their Java Cedar stack) took a long time to optimize and even with this small amount of JS would cause TimeoutErrors and fail the push. As a result, the only way I can see to make this work with Heroku is to check in my compiled files.
- There is currently a basic deploy (
deploy/deploy-heroku.sh) shell script (not extensively tested or generalized) which performs the following steps:
- Checks out the origin/master copy to a temporary directory
play optimizejsto generate any front-end changes (necessary for STAGING/PRODUCTION modes)
- Creates a git tag
- Commits the tag and results (if any) of the optimization (which writes to the
- Pushes the tag revision to heroku/master (which will deploy the app to Heroku)