Git Product home page Git Product logo

nodejs-dashboard's Introduction

nodejs-dashboard

Telemetry dashboard for node.js apps from the terminal!

Build Status

http://g.recordit.co/WlUvKhXqnp.gif

Determine in realtime what's happening inside your node process from the terminal. No need to instrument code to get the deets. Also splits stderr/stdout to help spot errors sooner.

Install Setup Usage Using with other programs CLI options Customizing layouts

NOTE: This module isn't designed for production use and should be limited to development environments.

Install

The preferred method is global install. npm install -g nodejs-dashboard

Local install works also; just use ./node_modules/.bin/nodejs-dashboard instead of nodejs-dashboard to execute.

Setup

The dashboard agent needs to be required by your app. There are two ways to do this:

Including via code

From within a dev.index.js script or other dev entry point simply require the nodejs-dashboard module.

// dev.index.js
require("nodejs-dashboard");
require("./index");

To launch: nodejs-dashboard node dev.index.js

Including via preload argument

This method utilizes Node's -r flag to introduce the nodejs-dashboard module. In this setup no code modifications are required. This is functionally equivalent to the above example.

To launch: nodejs-dashboard -- node -r nodejs-dashboard index.js

Fonts

nodejs-dashboard uses the Braille Unicode character set to show graphs via the node-drawille dependancy. Ensure your terminal program's font supports this character set.

Environment variables

nodejs-dashboard uses several environment variables to modify its behavior. These include some required values to prevent mangled output.

Variable Required Source Description
TERM required blessed Terminal value matching terminal program
LANG required blessed Matches encoding of terminal program to display font correctly
FORCE_COLOR optional chalk Used to force color output by the subprocess

Usage

Press ? to see a list of keybindings. Use arrow keys to change the layout.

You may want to add an npm script to to your package.json to launch your app using nodejs-dashboard using one of the options above. Example:

"scripts": {
  "dev": "nodejs-dashboard -- node -r nodejs-dashboard index.js"
}

Passing arguments

If your app requires additional arguments you'll need to use the -- flag to separate them from nodejs-dashboard options. For example:

nodejs-dashboard --port=8002 -- node -m=false --bar=true index.js

Launching your app with something other than node

Most CLI interfaces provide a mechanism for launching other tools. If you're looking to use something like nodemon or babel checkout the exec options provided by the CLI.

% nodemon --exec "nodejs-dashboard babel-node" src/index.js

Docker and Docker Compose support

nodejs-dashboard can run inside a container if that container has a TTY allocated to it. The Docker documentation shows how to run a container with an interactive terminal session. Additional the Docker Compose documentation indicates that docker-compose run defaults to allocating a TTY and docker-compose up defaults to not allocating one.

CLI options

Usage: nodejs-dashboard [options] -- [node] [script] [arguments]

Options:
  -h, --help                  output usage information
  -e, --eventdelay [ms]       Minimum threshold for event loop reporting, default 10ms
  -l, --layouts [file]        Path to file or npm module with layouts
  -p, --port [port]           Socket listener port
  -r, --refreshinterval [ms]  Metrics refresh interval, default 1000ms
  -s, --settings [settings]   Overrides layout settings for given view types           
  -V, --version               output the version number
--eventdelay

This tunes the minimum threshold for reporting event loop delays. The default value is 10ms. Any delay below this value will be reported at 0.

--layouts

Optionally supply a custom layout configuration (for details, see Customizing Layouts). Default: lib/default-layout-config.js

--port

Under the hood the dashboard utilizes SocketIO with a default port of 9838. If this conflicts with an existing service you can optionally change this value.

--refreshinterval

Specifies the interval in milliseconds that the metrics should be refreshed. The default is 1000 ms (1 second).

--settings

Overrides default or layout settings for views. Option value settings should have a format <view_type.setting.path>=<value>,.... For example --settings log.scrollback=100 will override scrollback setting for any view of log type (nested paths can be used if needed). For details about layouts, see Customizing Layouts).

Maintenance Status

Archived: This project is no longer maintained by Formidable. We are no longer responding to issues or pull requests unless they relate to security concerns. We encourage interested developers to fork this project and make it their own!

nodejs-dashboard's People

Contributors

aisapatino avatar alexkuz avatar bbohen avatar boygirl avatar dangkhue27 avatar dependabot[bot] avatar jasonwilson avatar jjasonclark avatar jpdriver avatar mscottx88 avatar ryan-roemer avatar steveslayden avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nodejs-dashboard's Issues

process.stdout.write no output

I have no output in the stdout view, when doing

const spinner = [ '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏' ];
process.stdout.write(" "+spinner[ (index+1)% spinner.length ]+"\r" );

Round CPU usage [suggestion]

cpuusage

As shown above, CPU usage is not rounded off. This may cause wrapping which might look less appealing. Consider rounding the number to a maximum of decimals to prevent this.

Bug: Linux shells cannot have dash-cased environment variable names.

No stats are collected when using nodemon. The dashboard app spawns the nodemon process which then spawns the actual node app. This is a bit different from using nodemon to reload the dashboard app if it terminates. (from issue #9)

Repo steps

  1. Install nodemon in the project. yarn add -D nodemon
  2. Execute test app with nodemon: node bin/nodejs-dashboard.js -- node_modules/.bin/nodemon --exec "node test/app/index.js"

no_graph

Outline of usage risks.

I'm curious about the risks related to using this package.

The docs say not to use it in production, but without outlining what the encountered or anticipated problems with the current version might be.

Providing an outline of risks can help a developer understand your reasons for this suggestion, enabling them to determine for themselves if those concerns are applicable for their project and at what point in their pipeline from dev/lab to stage to prod this should be removed.

How to exit?

I currently exit using Ctrl + C (Ubuntu OS) - is that the correct way to exit or is there a more elegant way?

Won't work when using foreman

This is my Procfile for my LoopbackJS app:

web: nodejs-dashboard node .

The problem:
If I run nf start, the console just clears and nothing shows up (Not even an error). My app uses a bunch of environment variables and foreman really makes it a breeze to run it.

The expected result:
The dashboard should appear in the terminal running the app. This actually does happen if I run nodejs-dashboard node . instead of nf start, it just fails with foreman.

Can I pipe the Stdout?

<praise>Splendid package, well done</praise>

My application uses Bunyan for logging. In order to make the output more readable, my original command is node ./app.js | bunyan.

When I change my command to nodejs-dashboard node ./app.js | bunyan, I just get the message "Waiting for client connection on 9838..." and nothing else.

If I get rid of the | bunyan pipe, it works fine (but with the stdout an unreadable mess).

Any ideas how to get my output piped?

latest version on npm is 0.3.0 but I don't see 0.3.0 in the github repo

greenkeeper just notified me that there's a 0.3.0 version available for this project, but I'm not seeing anything about 0.3.0 in this repo.

I also don't see any tags or releases of any kind, or any CHANGELOG to indicate what changed between 0.2.1 and 0.3.0.

can you provide some info on what changed and confirm that this was a legitimate publish to npm?

Memory leak

  • Node Version: Node v6.9.1
  • Package version: v0.1.1
  • Platform: SMP Debian 3.2.81-1 x86_64 GNU/Linux
    When I required this package, the memory began to grow slowly
    const dashboard = require("nodejs-dashboard");
    Memory schedule
    deepinscreenshot-5958
    Comparison of 2 heap shapshots
    0740fd1b21

Longer history for graphs

30m for cpu/event loop/memory graphs when they're full width.
Probably don't want to store individual per-second values, so would need to add aggregation to provider.

RangeError: "size" argument must not be negative

Just installed nodejs-dashboard globally, but I'm getting error.

Command: nodejs-dashboard -- node -r nodejs-dashboard index.js

Error code:

RangeError: "size" argument must not be negative
    at Function.Buffer.alloc (buffer.js:229:3)
    at new Buffer (buffer.js:152:19)
    at new Canvas (C:\Users\User\AppData\Roaming\npm\node_modules\nodejs-dashboard\node_modules\drawille-blessed-contrib\index.js:17:18)
    at new Context (C:\Users\User\AppData\Roaming\npm\node_modules\nodejs-dashboard\node_modules\drawille-canvas-blessed-contrib\index.js:11:18)
    at module.exports.Canvas.getContext (C:\Users\User\AppData\Roaming\npm\node_modules\nodejs-dashboard\node_modules\drawille-canvas-blessed-contrib\index.js:274:24)
    at Line.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\nodejs-dashboard\node_modules\blessed-contrib\lib\widget\canvas.js:22:29)
    at Line.EventEmitter._emit (C:\Users\User\AppData\Roaming\npm\node_modules\nodejs-dashboard\node_modules\blessed\lib\events.js:98:20)
    at Line.EventEmitter.emit (C:\Users\User\AppData\Roaming\npm\node_modules\nodejs-dashboard\node_modules\blessed\lib\events.js:117:12)
    at emit (C:\Users\User\AppData\Roaming\npm\node_modules\nodejs-dashboard\node_modules\blessed\lib\widgets\node.js:109:15)
    at Box.Node.insert (C:\Users\User\AppData\Roaming\npm\node_modules\nodejs-dashboard\node_modules\blessed\lib\widgets\node.js:111:5)

No charts with ts-node

This is more likely an issue on the ts-node side of things, but I'm not sure how the chart statistics are obtained to open up a topic over there.

Idea: Multiple tabs

Really nice work! I'm just opening this issue to submit an idea.

For applications that maybe have multiple processes running, what do you think about enabling tabs? Perhaps each application running could register itself to a display name and you could toggle between them using numbers. I could imagine spawning child processes that might render a new tab and then when it closes the tab disappears. Also for use with projects like https://github.com/strongloop/node-foreman, where you might have two process (web/worker) running and want to run them together.

Some ways it may work:

  • Pass a name on require, but this would break the current child.stdout approach (it might need to monkey patching process stdout instead)
  • Pass a flag to nodejs-dashboard --new-tab web that'll use the parent dashboard process to attach to it (this would likely mean a new tab results in two tabs - one for the overall process, one for the new tab child)

some error

RangeError [ERR_INVALID_OPT_VALUE]: The value "-63" is invalid for option "size"

Using babel-node and nodemon

nodejs-dashboard babel-node index.js works fine.

Dunno how to use it with both nodemon and babel-node.

This is the raw command i used earlier btw: nodemon index.js --exec babel-node

Support for Meteor

This is more of an idea and/or feature request, if at all possible. It would be useful to have this data while developing a Meteor application.

Thanks for the tool!

Text not selectable in the stream

Text is not selectable in the stdin and stdout stream. I guess it might be related to this chjj/blessed#263 but I'm not sure wether it's my config or it's more general.

It's not selectable in both iTerm and Terminal

Missing Package

When I run my app, I get the following error. (Installed the dashboard following the directions in the README from the repo.)

Failed to compile.

Error in ./~/nodejs-dashboard/~/pidusage/lib/stats.js
Module not found: 'child_process' in /Users/igreulich/apps/rhinofront/node_modules/nodejs-dashboard/node_modules/pidusage/lib

 @ ./~/nodejs-dashboard/~/pidusage/lib/stats.js 4:11-35 5:12-36

This is during the webpack build process. (I started the app with create-react-app but have since ejected it, am adding niceties.)

BUG: Flaky MetricsProvider tests in CI

I'm anecdotally seeing a lot of failures like:

  68 passing (24s)
  2 failing
  1) MetricsProvider _onMetrics retains metrics received, while aggregating them into time buckets:
     Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
  
  2) MetricsProvider _onMetrics aggregates data for non-uniform data sets too:
     Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

in Travis. Current incarnation: https://travis-ci.org/FormidableLabs/nodejs-dashboard/jobs/311447216 (I'm restarting this build so it may pass next time...)

strange terminal character output

added import to my server entrypoint:
import 'nodejs-dashboard';

added npm script like so:
"start:dev": "NODE_ENV=development nodemon --watch server --exec \"npm run build:schema && nodejs-dashboard babel-node server/index.js\""

get these escape characters after running for a minute or so:
screenshot 2016-10-12 22 26 43

this only occurs when my terminal is in rxvt mode, not in ansi mode.

Stdout and stderr not updating

I am consoling to stdout and stderr but dashboard updates with none of them. My index.js code is as follows:

require('nodejs-dashboard')
const http = require('http')  
const port = 4000

const requestHandler = (request, response) => {  
  console.log('Printing on stdout: ',request.url)
console.error('Printing on stderr')
  response.end('Hello Node.js Server!')
}

const server = http.createServer(requestHandler)

server.listen(port, (err) => {  
  if (err) {
    return console.log('something bad happened', err)
  }
  console.log(`server is listening on ${port}`)
})

The following should appear on stdout:

server is listening on 4000
Printing on stdout:  /

While I expect this line on stderr:
Printing on stderr

But this is what my dashboard looks like:

nodedash

Running with the Global Binary

I would ideally not want to touch my package.json/code base at all and run the dashboard via the binary itself.
Is it possible?
I did
nodejs-dashboard npm start It loads the dashboard but does not update the memory and processor usage part.

Run command parameters aren't forwarded to destination script

I have the following command in package.json -> "dev": "nodejs-dashboard node bin/server.js --env development"
The issue is that --env development doesn't get forwarded to server.js.

I've tested and the issue is that commander strips it and only keeps the command itself.

I'll try and provide a PR if I find the time!

LE: I know you can use "dev": "nodejs-dashboard -- node bin/server.js --env development" but I think it would be nice if it worked directly.

don't make us require it in the app

I suggest we find a way not to require it in index.js (you do suggest to install it as dev dependency which would mean it is not available in production)

possible solutions:

  • wrap it in a logical test on the environement >> not ideal, and bloat
  • wrap it in a separate dev.index.js which then loads index.js
  • ...

Harmony flags not working

This tool is awesome but I noticed that when I tried to get it running with an existing project the dashboard would display but nothing would run as the project supports Node v5.X while using harmony flags.

Works: "dashboard": "nodejs-dashboard node server.js"
Doesnt Work: "dashboard": "nodejs-dashboard node --harmony_destructuring server.js"

Not sure if the intention is that nodejs-dashboard would only support Node v6 and above (understandable) or if this is a bug/misunderstanding. If it is a bug I would be happy to try and get to the bottom of it when I have some free time later.

How is it monitoring my requests?

After installing and configuring the library, I ran some requests but it's not indicating in the terminal.

How do i go about that?

bash: nodejs-dashboard: command not found

I did:
"npm install nodejs-dashboard --save-dev"
added "require('nodejs-dashboard')" to the top of my app.js
ran "nodejs-dashboard node app.js" from the command-line and get this error:

"bash: nodejs-dashboard: command not found"

EDIT: Ran it in a npm script and it's beautiful. This will be on one of my monitors for all the projects I work on.

Resize graphs on terminal resize

After resizing the terminal, both the outputs and the graphs are resized as well. Only the outputs use this new space, the graphs stay small.

Tested with 1.0.1 on Ubuntu Trusty LTS (14.04)
smallgraphs

Error: Cannot find module 'nodejs-dashboard'

mac OS 10.13.3
node v 8.9.1
Tried on Hyper and iTerm

npm install -g nodejs-dashboard
nodejs-dashboard -- node -r nodejs-dashboard test.js

This starts the dashboard but gives me an error accessing the module...

screen shot 2018-03-29 at 14 06 53

Can't work on git-bash

Hello! Your work is awesome, but I've found it can not work in git-bash, all the output are mess code. Are there anything I did wrong, or nodejs-dashboard doesn't support git-bash yet?
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.