Comments (5)
Hey Christopher,
The initial command was working as expected:
$ node
> var Monitor = require('monitor');
undefined
undefined
is actually what the REPL displays whenever you assign a variable. Try this:
$ node
var a = 'hello';
undefined
From that point on, things went downhill fast. Running require('./node_modules/monitor/monitor.js');
starts the monitor server (cool!). It's the same as going into the monitor directory and entering
$ node monitor.js
Unfortunately this isn't the same as var Monitor = require('monitor');
because it doesn't assign the Monitor class to your variable. From that point on, the Monitor
variable doesn't represent a class that you can new
, so things didn't work very well.
Try running the commands in the REPL window just as they're shown in the example. I will update the example to show the undefined
return from the first command, because I can see how this can be confusing.
from node-monitor.
Aha! I should have known better. Thanks for working with a newb. ;)
The REPL example is working great! I'm seeing a memory change reported every second. The JSON data is exactly what I'm after for my custom app.
AHA! I figured it out. In the documented js example:
var Monitor = require('monitor');
needs to change to:
var Monitor = require('monitor').start();
Then I'm seeing stuff after adding a few test log messages (showing onchange being fired every 10 seconds as expected!).
Would you like me to attempt a pull-request? 💃
Thanks again.
from node-monitor.
Adding .start()
to the end of require('monitor')
starts the monitor server within the REPL, which is cool, but not necessary for this client-side example. The start()
command is necessary in your server, which should be running in another process while running the client-side example.
Does this make sense?
from node-monitor.
Yes, I think that makes sense. Since I'm creating a server script and not something that would run in the browser client (my server will talk to the browser client with this info and details from other services), I need to start it for the server. The client that connects to my server will not need that (and actually won't use it directly in my case).
Thanks for the clarification and assist!
from node-monitor.
I'll go ahead and close this.
from node-monitor.
Related Issues (20)
- Removing components HOT 2
- "Add component" needs scrollbar by default. HOT 1
- npm start monitor failed HOT 1
- Support for HTTP monitoring? HOT 1
- Test with a remote Server HOT 3
- Monitor an application from Browser HOT 2
- node-monitor crashes HOT 2
- error running monitor HOT 4
- Error watching for file (runtime.json) ENOSPC HOT 3
- Need more examples HOT 5
- process.EventEmitter is deprecated in Node.js v6.*.* HOT 4
- What about multiple processes? How are they handled? HOT 3
- Cannot get output when running a nodejs script file HOT 1
- How can I add additional data to the monitor result? HOT 4
- getConnection() return null
- Build error on install HOT 1
- Monitor information do not getting correctly in docker container HOT 1
- Waiting for response HOT 1
- Page onInit doesn't save HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-monitor.