Skip to content

Commit 6796dcb

Browse files
jehartzoglmachens
authored andcommitted
Provide working MUP deployment template and guide (#25)
* Add package.json and package-lock.json for MUP * Add template MUP deploy script * Create default settings.json file * Update readme with new MUP setup steps * use `meteor npm install` instead of `npm install`
1 parent f1a54e7 commit 6796dcb

File tree

5 files changed

+7296
-30
lines changed

5 files changed

+7296
-30
lines changed

README.md

+55-30
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,73 @@
11
# APM
22

3-
This project reduces the original Kadira APM to a single Meteor project.
4-
Most of the original features are working (like Slack alerts), but there is still a lot of work.
5-
Feel free to contribute!
3+
This project reduces the original Kadira APM to a single Meteor project and includes template MUP configuration to let you deploy to any remote server.
64

7-
## Running it
5+
Most of the original features are working (like Slack alerts), but there is still a lot of work. Feel free to contribute!
86

9-
A mongo replica set is required!
7+
## Get up and running with MUP
108

11-
```
12-
cd apm
13-
meteor npm i
14-
meteor
15-
```
9+
The easiest way to get this server up and running is to use the recommended configuration with [MUP](https://github.com/zodern/meteor-up).
1610

17-
This opens the following ports:
11+
### Setup steps
1812

19-
* UI: 3000
20-
* RMA: 11011
21-
* API: 7007
13+
1) Clone this repo and run `meteor npm install`.
2214

23-
## Login
15+
2) Copy [`mup-placeholder.js`](mup-placeholder.js) to `mup.js`. Replace the placeholder entries in the configuration with your configuration.
2416

25-
26-
password: admin
17+
3) Server configuration steps you need to verify prior to deployment:
2718

28-
## Meteor apm settings
29-
`metricsLifetime` sets the maximum lifetime of the metrics. Old metrics are removed after each aggregation.
30-
The default value is 604800000 (1000 * 60 * 60 * 24 * 7 ^= 7 days).
19+
a) This setup was tested using a server with at least 512MB of RAM.
3120

32-
```
33-
"metricsLifetime": 604800000
34-
```
21+
b) Allow public access to your server on the following ports: 22, 80, 443, 7007, 11011.
22+
23+
c) In order for SSL configuration to succeed, you must set setup your DNS to point to your server IP address prior to deployment. Make sure to point both `apm.YOUR_DOMAIN.com` and `apm-engine.YOUR_DOMAIN.com` to the same server IP address.
3524

36-
## Meteor client settings
25+
4) Run `npm run mup-deploy`.
26+
27+
5) Visit your APM UI page at `https://apm.YOUR_DOMAIN.com`. Login with username `[email protected]`, password `admin`. **CHANGE YOUR PASSWORD FROM THIS DEFAULT**.
28+
29+
6) In the APM web UI, create a new app and pass the settings to your Meteor app:
30+
31+
`settings.json`
3732
```
38-
"kadira": {
39-
"appId": "...",
40-
"appSecret": "...",
33+
{
34+
...
35+
"kadira": {
36+
"appId": "YOUR_APM_APP_ID",
37+
"appSecret": "YOUR_APM_APP_SECRET",
4138
"options": {
42-
"endpoint": "http://localhost:11011"
39+
"endpoint": "https://apm-engine.YOUR_DOMAIN.com"
4340
}
44-
},
41+
},
42+
}
43+
```
44+
45+
7) Re-deploy your Meteor app, and you should see data populating in your APM UI in seconds.
46+
47+
## Server Restarts
48+
49+
The custom nginx proxy configuration does not persist through a server restart. There is no current way to hook this into MUP easily, so you will need to run `npx mup deploy` again if you need to restart the server. This should not be a problem with normal operation.
50+
51+
## Meteor apm settings
52+
[`metricsLifetime`](settings.json) sets the maximum lifetime of the metrics. Old metrics are removed after each aggregation. The default value is 604800000 (1000 * 60 * 60 * 24 * 7 ^= 7 days).
53+
54+
As a baseline, a current Meteor application with ~500 DAL uses 0.7 GB for 7 days of APM data.
55+
56+
## Configuration details:
57+
58+
If you want to do custom configuration and server setup, here are items to be aware of:
59+
60+
1) A mongo replica set is required. This is set up automatically for you when using the template MUP configuration script.
61+
62+
2) If you are not getting APM data and see a [No 'Access-Control-Allow-Origin' header is present](#14) console error in your Meteor app, this is due to incorrect nginx proxy configuration. To confirm the issue, ssh into your server (`npx mup ssh`) and run `docker exec mup-nginx-proxy cat /etc/nginx/conf.d/default.conf`. Look for the upstream block for `apm-engine.YOUR_DOMAIN.com`, the entry should look like
4563
```
64+
upstream apm-engine.YOUR_DOMAIN.com {
65+
# YOUR_APP
66+
server SOME_IP:11011;
67+
}
68+
```
69+
70+
If you see port 80 for that setting, the MUP hook that tries to update this port may be failing.
4671

4772
## Changes to original Kadira
4873

@@ -56,4 +81,4 @@ The default value is 604800000 (1000 * 60 * 60 * 24 * 7 ^= 7 days).
5681
## ToDo
5782

5883
* Direct db access of alertsman (apm/server/alertsman/server.js) and remove api (apm/server/api/server.js)
59-
* Replace invalid links to old kadira docs
84+
* Replace invalid links to old kadira docs

mup-placeholder.js

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copy this file to mup.js and replace placeholders with your info
2+
module.exports = {
3+
servers: {
4+
one: {
5+
host: 'YOUR_SERVER_IP',
6+
username: 'ubuntu',
7+
pem: '~/.ssh/id_rsa.YOUR_PRIVATE_SSH_KEY',
8+
}
9+
},
10+
11+
app: {
12+
name: 'YOUR_APP-apm',
13+
path: './apm',
14+
servers: {
15+
one: {},
16+
},
17+
buildOptions: {
18+
serverOnly: true,
19+
},
20+
env: {
21+
ROOT_URL: 'https://apm.YOUR_DOMAIN.com',
22+
MONGO_URL: 'mongodb://localhost/meteor',
23+
MONGO_OPLOG_URL: 'mongodb://mongodb/local'
24+
},
25+
docker: {
26+
image: 'abernix/meteord:node-8.4.0-base',
27+
args: [
28+
'-p 11011:11011', // Open up the engine port
29+
'--log-driver json-file', // Without these the Docker log file for Mongo will exhaust disk space
30+
'--log-opt max-size=100m',
31+
'--log-opt max-file=3',
32+
],
33+
},
34+
enableUploadProgressBar: true,
35+
},
36+
37+
proxy: {
38+
domains: 'apm.YOUR_DOMAIN.com,apm-engine.YOUR_DOMAIN.com',
39+
ssl: {
40+
forceSSL: true,
41+
letsEncryptEmail: 'contact@YOUR_DOMAIN.com',
42+
},
43+
},
44+
45+
mongo: {
46+
version: '3.4.1',
47+
servers: {
48+
one: {},
49+
},
50+
},
51+
52+
hooks: {
53+
// Using remoteCommand would be simpler here, but it was not working
54+
'post.meteor.start'(api) {
55+
return api.runSSHCommand(
56+
api.getConfig().servers.one,
57+
"docker exec mup-nginx-proxy sed -i '0,/server.*:80/ s/\\(server.*:\\)80/\\111011/1' /etc/nginx/conf.d/default.conf && docker exec mup-nginx-proxy nginx -s reload",
58+
);
59+
},
60+
},
61+
};

0 commit comments

Comments
 (0)