-
Notifications
You must be signed in to change notification settings - Fork 19
/
README
92 lines (53 loc) · 3.05 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
Prerequisites
=============
Install play on MacOS using homebrew
------------------------------------
brew install --devel play
Importing the project in IntelliJ IDEA v. 12.x
----------------------------------------------
0/ Make sure you have the scala plugin install
1/ Install sbt
brew install sbt
2/ Install gen-idea sbt plugin [https://github.com/mpeltonen/sbt-idea]
Add the following lines to ~/.sbt/plugins/build.sbt or PROJECT_DIR/project/plugins.sbt
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.2.0")
3/ Create idea project files
./sbt gen-idea
4/ Open project in IDEA
This is your new Play 2.0 application
=====================================
Optional Environment Variables
------------------------------
The app can run with the default settings from conf/application.conf.
export LSUG_MEETUP_GROUP_ID="..."
export LSUG_MEETUP_KEY="..."
# for http://lsug.org
export LSUG_MEETUP_ID="8hb7m06tmkrv44thc9q2qvtcc3"
# alternatively for http://localhost:9000
export LSUG_MEETUP_ID="6uaao0sbsmt6u6rj17v4lu5u9"
export LSUG_MONGODB_DEFAULT_URI="..."
Environment Variables on Heroku
-------------------------------
You can configure environment variables in heroku and use "foreman start" locally to run the app as it would run on heroku.
https://devcenter.heroku.com/articles/config-vars
Configuring MongoLabs with Play
-------------------------------
How to configure MongoDB with Play when running MongoLabs addon in Heroku.
Heroku gives you a default name for your database. If you look in the configuraiton for your Heroku application then you can see the URI
heroku config
or
herok config ¦ grep mongo
This will give you a URI that is also set in the environment variable MONGOLAB_URI.
Is it enough to just add this to the Procfile for you Play app
-Dmongodb.uri=$MONGOLAB_URI
Or do you also need to include it in your play framework configuration in config/application.conf
# MongoURI
# ~~~~~
# a MongoURI can also be used http://www.mongodb.org/display/DOCS/Connections
# mongodb.default.uri = "mongodb://127.0.0.1:27017,mongodb.org:1337/salat-test"
Using the universal resource indicator directly in the application.conf will work when running play2 / mongo application on your development machine and heroku. However, there is an obvious issue that you may not want to change the contents of your app on heroku and use the same db for both environments leads to this issue.
If you have a seperate mongodb locally, then you have more scope for experimenting.
You can have different configs for local and heroku, but its not as nice as having a common configuation. It can also lead to deploying the wrong config to github / heroku with unpleasent side effects.
If you assume you have mongo also running locally, in theory so long as you have the same database name and are using the defaults, then it should work by having a common configuration.
mongodb.default.uri="mongodb://127.0.0.1:27017/dbname"
Can you just get the Procfile to set things up. This would require the running of the program to send an environment variable to the play framework when run.