File tree 4 files changed +87
-0
lines changed
4 files changed +87
-0
lines changed Original file line number Diff line number Diff line change 2
2
.settings
3
3
.project
4
4
.DS_Store
5
+ .vagrant
5
6
target
Original file line number Diff line number Diff line change
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant . configure ( "2" ) do |config |
5
+ config . vm . box = "ubuntu/trusty64"
6
+ config . vm . provider "virtualbox" do |v |
7
+ v . memory = 2048
8
+ end
9
+ config . vm . network :forwarded_port , guest : 8080 , host : 8180
10
+ config . vm . network :forwarded_port , guest : 8081 , host : 8181
11
+ config . vm . network :forwarded_port , guest : 27017 , host : 27017
12
+ config . vm . network :forwarded_port , guest : 28017 , host : 28017
13
+ config . vm . provision :shell , :path => "provision.sh"
14
+ end
Original file line number Diff line number Diff line change
1
+ # Dropwizard Mongo Example
2
+
3
+ This example shows how to add mongo configuration to your Dropwizard project.
4
+
5
+ ## Before You Begin
6
+
7
+ - Make sure you have build the project using the instructions in the parent project.
8
+ - These instructions assume that the example project is your current working directory.
9
+
10
+ ## Starting the Server
11
+
12
+ The mongo password in the example is encrypted, so you will need to set the encryption passphrase in your environment
13
+ before starting the server.
14
+
15
+ ```
16
+ export DROPWIZARD_PASSPHRASE='correct horse battery staple`
17
+ ```
18
+
19
+ Also, we will need to start an instance of mongo to use the application with. There is a vagrant file in the root
20
+ directory that will start a VM, install mongo and add our example user.
21
+
22
+ ```
23
+ vagrant up
24
+ ```
25
+
26
+ Once vagrant has started, we can start the server.
27
+
28
+ ```
29
+ ./target/dropwizard-mongo server conf/example.yml
30
+ ```
31
+
32
+ That is it, the example application should be running.
33
+
34
+ ## Health Check
35
+
36
+ To make sure that the example is really working, you can curl the health resource on the admin port.
37
+
38
+ ```
39
+ curl http://localhost:8081/healthcheck
40
+ ```
41
+
42
+ You should see output like this if everything started properly.
43
+
44
+ ```
45
+ {"deadlocks":{"healthy":true},"mongo":{"healthy":true}}
46
+ ```
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # configure apt for mongo install
4
+ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
5
+ echo ' deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
6
+
7
+ # add source for Java 8
8
+ sudo add-apt-repository -y ppa:webupd8team/java
9
+
10
+ sudo apt-get update
11
+
12
+ # install mongo
13
+ sudo apt-get install -y mongodb-org=2.6.4 mongodb-org-server=2.6.4 mongodb-org-shell=2.6.4 mongodb-org-mongos=2.6.4 mongodb-org-tools=2.6.4
14
+
15
+ # reconfigure mongo to bind to all interfaces.
16
+ sudo sed -i" " ' s/^bind_ip = 127.0.0.1/bind_ip = 0.0.0.0/' /etc/mongod.conf
17
+
18
+ # restart mongo to apply config changes.
19
+ sudo service mongod restart
20
+
21
+ # install Java 8
22
+ echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
23
+ sudo apt-get install oracle-java8-installer --assume-yes
24
+
25
+ # add the example user.
26
+ mongo example --eval ' db.createUser({user: "example", pwd: "example", roles: ["readWrite"]});'
You can’t perform that action at this time.
0 commit comments