Code Monkey home page Code Monkey logo

Comments (5)

lorenwest avatar lorenwest commented on July 2, 2024

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.

owntheweb-archive avatar owntheweb-archive commented on July 2, 2024

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.

lorenwest avatar lorenwest commented on July 2, 2024

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.

owntheweb-archive avatar owntheweb-archive commented on July 2, 2024

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.

owntheweb-archive avatar owntheweb-archive commented on July 2, 2024

I'll go ahead and close this.

from node-monitor.

Related Issues (20)

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.