当像快递中间件一样使用时,deployd的仪表板

时间:2015-06-30 02:12:40

标签: node.js express deployd

我刚刚开始使用NodeJS并希望使用 deployd ,例如 Express 中间件( 使用此文档 - http://docs.deployd.com/docs/server/work-with-express.html)。

但我不了解路由器的工作情况(现在对我来说太深了)。所以,我无法访问仪表板。

所以,这里有一个有点无礼的问题 - 当我使用像中间件这样的deployd时,我怎样才能达到仪表板? 我的应用程序只是通过快速生成器生成,看起来像这样:

/**
 * Module dependencies.
 */

var app = require('../app');
var debug = require('debug')('truckDeploy:server');
var http = require('http');
var ENV = process.env.NODE_ENV || 'development';

/**
 * Get port from environment and store in Express.
 */

var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);

/**
 * Create HTTP server.
 */

var server = http.createServer(app);

var io = require('socket.io').listen(server, {'log level': 0});

// setup deployd
require('deployd').attach(server, {
  socketIo: io,  // if not provided, attach will create one for you.
  env: ENV,
  db: {host:'localhost', port:27017, name:'truck-db'}
});

/**
 * Listen on provided port, on all network interfaces.
 */

app.use(server.handleRequest);
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);

/**
 * Normalize a port into a number, string, or false.
 */

function normalizePort(val) {
  var port = parseInt(val, 10);

  if (isNaN(port)) {
    // named pipe
    return val;
  }

  if (port >= 0) {
    // port number
    return port;
  }

  return false;
}

/**
 * Event listener for HTTP server "error" event.
 */

function onError(error) {
  if (error.syscall !== 'listen') {
    throw error;
  }

  var bind = typeof port === 'string'
    ? 'Pipe ' + port
    : 'Port ' + port;

  // handle specific listen errors with friendly messages
  switch (error.code) {
    case 'EACCES':
      console.error(bind + ' requires elevated privileges');
      process.exit(1);
      break;
    case 'EADDRINUSE':
      console.error(bind + ' is already in use');
      process.exit(1);
      break;
    default:
      throw error;
  }
}

/**
 * Event listener for HTTP server "listening" event.
 */

function onListening() {
  var addr = server.address();
  var bind = typeof addr === 'string'
    ? 'pipe ' + addr
    : 'port ' + addr.port;
  debug('Listening on ' + bind);
}

1 个答案:

答案 0 :(得分:1)

根据您在运行代码后需要访问的文档http://localhost:3000/dashboard/

  

要在没有密钥的情况下访问/仪表板,必须运行Deployd并将env选项设置为development。

这是假设

var app = require('../app');

相当于实例化快递应用程序:

var app = require('express')();