monitor.js 674 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * Component for monitor.
  3. * Load and start monitor client.
  4. */
  5. var Monitor = require('../monitor/monitor');
  6. /**
  7. * Component factory function
  8. *
  9. * @param {Object} app current application context
  10. * @return {Object} component instances
  11. */
  12. module.exports = function(app, opts) {
  13. return new Component(app, opts);
  14. };
  15. var Component = function(app, opts) {
  16. this.monitor = new Monitor(app, opts);
  17. };
  18. var pro = Component.prototype;
  19. pro.name = '__monitor__';
  20. pro.start = function(cb) {
  21. this.monitor.start(cb);
  22. };
  23. pro.stop = function(force, cb) {
  24. this.monitor.stop(cb);
  25. };
  26. pro.reconnect = function(masterInfo) {
  27. this.monitor.reconnect(masterInfo);
  28. };