在网页

时间:2015-07-20 01:12:25

标签: node.js express pug javascript

extend layout
block content

script.
  var monitor = require("os-monitor");

  monitor.start();

  monitor.start({
     delay: 3000
     , freeman: 1000000000
     , uptime: 1000000
     , critical1: 0.7
     , critical5: 0.7
     , critical15: 0.7
     , silent: false
     , stream: false
     , immediate: false
  });
  monitor.on('monitor',function(event) {
     console.log(event.type, 'This event always happens on each monitor cycle!');
  });
  monitor.on('loadavg1',function(event) {
     console.log(event.type, 'Load average is exceptionally high!');
  });
  monitor.on('freemem',function(event) {
     console.log(event.type, 'Free memory is very low!');
  });
  monitor.throttle('loadavg5',function(event) {
  },monitor,minutes(5));
  monitor.config({
     freemem: 0.3
  });
  monitor.stop();
  monitor.isRunning();
  monitor.start({stream:true}).pipe(process.stdout);



block side bar
  .widget
     h1 Widget
     p
     | Sed ccccc rhoncus ut
     | eleifvvvv in nulla enim.
     p
     | Vivambbbbbbbbbbbbt molestie
     | vebula.

var express = require('express');
var stylus = require('stylus');
var nib = require('nib');

var app = express();

function compile(str, path) {
  return stylus(str)
	.set('filename', path)
	.use(nib())
}
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.logger('dev'));
app.use(stylus.middleware({
  src: __dirname + '/public',
  compile: compile
}));
app.use(express.static(__dirname + '/public'));

app.get('/', function(req, res) {
  res.render('index', {
	title: 'Home'
  })
});
app.listen(3000, function() {
  console.log('Server start http://localhost:3000');
});
我用jade创建了一个简单的网站和服务器作为node.js。 我希望网站显示进程状态,不仅仅是在终端中,所以我找到了一些模块(npm os-monitor,cpu-usage)来检查我的进程状态。但我不知道如何在网上运行它们。

1 个答案:

答案 0 :(得分:0)

你可能最好只使用像socket.io之类的东西来将数据从服务器传送到浏览器。在服务器上使用os-monitor或其他任何模块(在app.js中),然后广播或单独将数据发送到浏览器客户端。