Skip to content

Latest commit

 

History

History
59 lines (48 loc) · 1.65 KB

README.md

File metadata and controls

59 lines (48 loc) · 1.65 KB

Memshaw

Monitor your hapi application's memory footprint.

Screenshot

Inspired by PubNub-Rickshaw-Memory, this plugin displays a realtime graph of your NodeJS memory profile over time. It uses socket.io for pushing data to the browser and Shutterstock's Rickshaw library for graphing.

Usage

Hapi 16

  1. Add the memshaw plugin to your hapi installation, here I am using a manifest file with the glue plugin:
{
  ...
  registrations: [
    { plugin: { register: 'memshaw' } },
    ...
  ]
}
  1. Visit your application in the browser using the /memshaw path i.e. localhost:3000/memshaw

  2. Get your app to chew on some memory! For example you could have a terrible route that you curl http://localhost:3000/stress like this:

server.route({
  method: 'GET',
  path: '/stress',
  handler: (request, reply) => {
    const stupidBigArray = [];
    fs.createReadStream('/path/to/big/file', 'utf8')
      .on('data', (chunk) => {
        console.log('got %d bytes of data', chunk.length);
        stupidBigArray.push(chunk);
      });
    reply('Why are you pushing all these chunks to an array?');
  },
});

Hapi 17

const hapi = require('hapi');
const memshaw = require('memshaw/hapi-17');

(async function() {
  const server = hapi.server({port: 3000});

	await server.register([
			memshaw,
	]);

  await server.start();
})();

Resources

Rickshaw example