Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Commit

Permalink
[nodejs] Add appmetrics-dash as a dev dependency (#55)
Browse files Browse the repository at this point in the history
* Add appmetrics-dash as a dev dependency

* Update docs for appmetrics-dash

* Update version in package.json
  • Loading branch information
seabaylea authored and neeraj-laad committed Jul 8, 2019
1 parent 3faca5d commit 9776d92
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 10 deletions.
9 changes: 8 additions & 1 deletion incubator/nodejs-express/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ This stack also comes with Prometheus metrics, which has been preconfigured to w

- Metrics endpoint: http://localhost:3000/metrics

## Application monitoring dashboard (development only)

During development of your application, the nodejs-express stack provides a built-in application performance dashboard using the [appmetrics-dash](https://github.com/runtimetools/appmetrics-dash) module. This makes it easy to see the resource usage and HTTP endpoint performance of your application as it is developed.

The dashboard is only included during development, and is not included in images build using `appsody build`.

## Templates

Templates are used to create your local project and start your development. When initializing your project you will be provided with the simplest Node.js Express application you can write.
Expand Down Expand Up @@ -62,4 +68,5 @@ This template only has a simple `app.js` file which implements the `/` endpoint.
- Health endpoint: http://localhost:3000/health
- Liveness endpoint: http://localhost:3000/live
- Readiness endpoint: http://localhost:3000/ready
- Metrics endpoint: http://localhost:3000/metrics
- Metrics endpoint: http://localhost:3000/metrics
- Dashboard endpoint: http://localhost:3000/appmetrics-dash (development only)
5 changes: 3 additions & 2 deletions incubator/nodejs-express/image/project/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nodejs-express",
"version": "0.2.0",
"version": "0.2.1",
"description": "Node.js Express Stack",
"license": "Apache-2.0",
"repository": {
Expand All @@ -21,6 +21,7 @@
"devDependencies": {
"chai": "^4.2.0",
"mocha": "~6.1.0",
"request": "^2.88.0"
"request": "^2.88.0",
"appmetrics-dash": "^4.1.0"
}
}
4 changes: 4 additions & 0 deletions incubator/nodejs-express/image/project/server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Requires statements and code for non-production mode usage
if (!process.env.NODE_ENV || !process.env.NODE_ENV === 'production') {
require('appmetrics-dash').attach();
}
const express = require('express');
const health = require('@cloudnative/health-connect');
const fs = require('fs');
Expand Down
2 changes: 1 addition & 1 deletion incubator/nodejs-express/stack.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id: nodejs-express
name: Node.js Express application
version: 0.2.0
version: 0.2.1
description: Simple Node.js Express application with health checks and application metrics for Prometheus.
maintainer: Neeraj Laad <neeraj.laad@gmail.com>
default-template: simple
Expand Down
6 changes: 5 additions & 1 deletion incubator/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

The Node.js stack provides a consistent way of developing [Node.js](https://nodejs.org/) applications. As an asynchronous event-driven JavaScript runtime, Node is designed to build scalable network applications.

This stack is based on the `Node.js v10` runtime and allows you to develop new or existing Node.js application using Appsody.
This stack is based on the `Node.js v10` runtime and allows you to develop new or existing Node.js application using Appsody.

Additionally, if you are developing an applicaton that includes a HTTP server or a web framework such as Express.js,the stack provides a built-in application performance dashboard using the [appmetrics-dash](https://github.com/runtimetools/appmetrics-dash) module. This makes it easy to see the resource usage and HTTP endpoint performance of your application as it is developed.

The dashboard is only included during development, and is not included in images build using `appsody build`.

## Templates

Expand Down
10 changes: 6 additions & 4 deletions incubator/nodejs/image/Dockerfile-stack
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ ENV APPSODY_WATCH_REGEX="^.*.js$"

ENV APPSODY_INSTALL="npm install"

ENV APPSODY_RUN="npm start"
ENV APPSODY_RUN_ON_CHANGE="npm start"
ENV APPSODY_RUN="npm start --node-options --require=appmetrics-dash/attach"
ENV APPSODY_RUN_ON_CHANGE="npm start --node-options --require=appmetrics-dash/attach"
ENV APPSODY_RUN_KILL=true

ENV APPSODY_DEBUG="npm start --node-options --inspect=0.0.0.0"
ENV APPSODY_DEBUG_ON_CHANGE="npm start --node-options --inspect=0.0.0.0"
ENV APPSODY_DEBUG="npm start --node-options --inspect=0.0.0.0 --require=appmetrics-dash/attach"
ENV APPSODY_DEBUG_ON_CHANGE="npm start --node-options --inspect=0.0.0.0 --require=appmetrics-dash/attach"
ENV APPSODY_DEBUG_KILL=true

ENV APPSODY_TEST="npm test"
ENV APPSODY_TEST_ON_CHANGE=""
ENV APPSODY_TEST_KILL=false

COPY ./project /project
RUN cd /project;npm install

WORKDIR /project/user-app

ENV PORT=3000
Expand Down
16 changes: 16 additions & 0 deletions incubator/nodejs/image/project/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "nodejs",
"version": "0.2.1",
"description": "Node.js Stack",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/appsody/stacks.git",
"directory": "incubator/nodejs/image/project"
},
"dependencies": {
},
"devDependencies": {
"appmetrics-dash": "^4.1.0"
}
}
2 changes: 1 addition & 1 deletion incubator/nodejs/stack.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id: nodejs
name: Node.js application
version: 0.2.0
version: 0.2.1
description: Simple Node.js application
maintainer: Neeraj Laad <neeraj.laad@gmail.com>
default-template: simple
Expand Down

0 comments on commit 9776d92

Please sign in to comment.