Skip to content

Commit 54b5fff

Browse files
authored
Merge pull request #18 from oslabs-beta/justin/screen_recording
Justin/screen recording
2 parents 3d20c18 + 1fffade commit 54b5fff

File tree

11 files changed

+56
-19
lines changed

11 files changed

+56
-19
lines changed

examples/microservices/README.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,36 @@ Microservices architecture for testing [Chronos](https://github.com/open-source-
44

55
## Purpose and Design
66
This sample microservices architecture allows developers to explore the functionality of Chronos. It consists of four microservices, which are contained within the directories:
7-
- Reverse Proxy
8-
- Books
9-
- Customers
10-
- Orders
7+
- books
8+
- customers
9+
- orders
10+
- reverse_proxy
1111

1212
Each microservice has its own server, which receives requests from both the client and from other microservices. Books, Customers, and Orders also have their own databases, which they can query to respond to those requests.
1313

14-
## Steps to Run Example
15-
1. Create a single .env file in the *examples/microservices* folder with the following key/value pairs:
14+
## To Set Up Database for Storing/Retrieving Metrics
15+
Create a single .env file in the *examples/microservices* folder with the following key/value pairs:
1616
- `CHRONOS_DB`: `MongoDB` or `PostgreSQL`
17-
- `CHRONOS_URI`: The URI to the desired MongoDB or PostgreSQL database to save health metrics via **Chronos**
18-
- `BOOK_URI`: A **MongoDB** URI for the bookserver microservice to use
19-
- `CUSTOMER_URI`: A **MongoDB** URI for the customerserver microservice to use
20-
- `ORDER_URI`: A **MongoDB** URI for the orderserver microservice to use
17+
- `CHRONOS_URI`: The URI to the desired MongoDB or PostgreSQL database to save health metrics via **Chronos NPM Package**
18+
- `BOOK_URI`: A **MongoDB** URI for the `books` microservice to use
19+
- `CUSTOMER_URI`: A **MongoDB** URI for the `customers` microservice to use
20+
- `ORDER_URI`: A **MongoDB** URI for the `orders` microservice to use
2121

22+
Note: The `CHRONOS_URI` and all microservice `_URI`'s can be the same URI if you use MongoDB. You may run out of space in your database if the services run for an extended period of time. You can temporarily solve this by creating separate databases, or manually deleting the collection from the database regularly using a UI such as MongoDB Compass. When running, the microservices will create new collections if none are found in the database.
2223

23-
Peform the following steps in each of the *books*, *customers*, *orders*, and *reverse proxy* directories
24+
## Start the Microservices
25+
Peform the following steps in each of the *books*, *customers*, *orders*, and *reverse_proxy* directories
2426
1. `cd` into the folder
2527
2. Look at `package.json` to note where `@chronosmicro/tracker` is being imported from. Verify that it is coming from the desired location (whether the published remote from npm or from local directory).
2628
3. Run `npm install`
2729
4. Run `npm run start`
2830

31+
**Mac Users:** Alternative to the above list of steps, `cd` into the `scripts` folder and run the `startMicroservices.sh` script
32+
2933
#
30-
Then open a web browser to `localhost:3000` and verify that the simple webpage application is operational.
34+
Then open a web browser to `localhost:3000` and verify that the simple webpage application is operational. You can use the web app if you wish, but it is not necessary for retrieving and visualizing health metrics in Chronos.
3135

32-
Your microservice health metrics can now be viewed at the given `CHRONOS_URI` or, preferrably, in the Electron.js desktop application.
36+
Your microservice health metrics can now be viewed in the given `CHRONOS_URI` database, or, preferrably, in the Electron.js desktop application.
3337
#
3438

3539
## Contributing

examples/microservices/books/BookModel.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ require('dotenv').config({
66
const mongoose = require('mongoose');
77
const { Schema } = mongoose;
88

9-
// UNCOMMENT THE LINE BELOW AND REPLACE WITH AN ACTUAL MONGODB URI FOR YOUR "CUSTOMERS" DATABASE
10-
require('./chronos-config'); // Bring in config file
9+
require('./chronos-config');
10+
/**
11+
* Your .env file's BOOK_URI will be referenced here to connect the
12+
* `books` microservice metrics to your database.
13+
*/
1114
const myURI = process.env.BOOK_URI;
1215

1316
mongoose.connect(myURI, { useNewUrlParser: true, useUnifiedTopology: true })

examples/microservices/customers/CustomerModel.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ require('dotenv').config({
66
const mongoose = require('mongoose');
77
const { Schema } = mongoose;
88

9-
require('./chronos-config'); // Bring in config file
9+
require('./chronos-config');
10+
/**
11+
* Your .env file's CUSTOMER_URI will be referenced here to connect the
12+
* `customers` microservice metrics to your database.
13+
*/
1014
const myURI = process.env.CUSTOMER_URI;
1115

1216
mongoose.connect(myURI, { useNewUrlParser: true, useUnifiedTopology: true })

examples/microservices/orders/OrderModel.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ require('dotenv').config({
66
const mongoose = require('mongoose');
77
const { Schema } = mongoose;
88

9-
// UNCOMMENT THE LINE BELOW AND REPLACE WITH AN ACTUAL MONGODB URI FOR YOUR "ORDERS" DATABASE
10-
require('./chronos-config'); // Bring in config file
9+
require('./chronos-config');
10+
/**
11+
* Your .env file's ORDER_URI will be referenced here to connect the
12+
* `orders` microservice metrics to your database.
13+
*/
1114
const myURI = process.env.ORDER_URI;
12-
// const myURI = 'mongodb+srv://johndoe:[email protected]/';
1315

1416
mongoose.connect(myURI, { useNewUrlParser: true, useUnifiedTopology: true })
1517
.then(() => console.log('Connected!!!********* Order Database is live!!!'))
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
cd ../books
3+
dir=$(pwd)
4+
com="cd $dir && npm install && npm run start"
5+
echo Starting books microservice. A Mac Terminal App should be open and contains more information.
6+
osascript -e "tell app \"Terminal\" to do script \"$com\""
7+
8+
cd ../customers
9+
dir=`pwd`
10+
com="cd $dir && npm install && npm run start"
11+
echo Starting customers microservice. A Mac Terminal App should be open and contains more information.
12+
osascript -e "tell app \"Terminal\" to do script \"$com\""
13+
14+
cd ../orders
15+
dir=$(pwd)
16+
com="cd $dir && npm install && npm run start"
17+
echo Starting orders microservice. A Mac Terminal App should be open and contains more information.
18+
osascript -e "tell app \"Terminal\" to do script \"$com\""
19+
20+
cd ../reverse_proxy
21+
dir=$(pwd)
22+
com="cd $dir && npm install && npm run start"
23+
echo Starting reverse_proxy microservice. A Mac Terminal App should be open and contains more information.
24+
osascript -e "tell app \"Terminal\" to do script \"$com\""

0 commit comments

Comments
 (0)