Permalink
Browse files

added ability to bind ip address

  • Loading branch information...
1 parent 3224d53 commit 6c6c554dcfab2474f5ec1d6bfa0c2e37e25773dc Shulhi Sapli committed Jan 26, 2014
Showing with 9 additions and 6 deletions.
  1. +1 −1 assets/init/_config.yml
  2. +1 −1 lib/plugins/console/index.js
  3. +7 −4 lib/plugins/console/server.js
View
@@ -58,7 +58,7 @@ tag: 2
## You can customize the logger format as defined in
## http://www.senchalabs.org/connect/logger.html
port: 4000
-server_address: localhost
+server_ip: 0.0.0.0 # bind to all ip address by default
logger: false
logger_format:
@@ -87,7 +87,7 @@ var serverOptions = {
alias: 's',
desc: 'Start the server and watch for file changes.',
options: [
- {name: '-a, --address', desc: 'Override the default server address. Default is localhost'},
+ {name: '-i, --ip', desc: 'Override the default server ip. Bind to all ip address by default'},
{name: '-p, --port', desc: 'Override the default port'},
{name: '-s, --static', desc: 'Only serve static files'},
{name: '-l, --log [format]', desc: 'Enable logger. Override the logger format.'},
@@ -9,7 +9,7 @@ module.exports = function(args, callback){
processor = hexo.extend.processor;
var app = express(),
- serverAddress = args.a || args.address || config.server_address || 'localhost',
+ serverIp = args.i || args.ip || config.server_ip || '0.0.0.0',
port = parseInt(args.p || args.port || config.port, 10) || 4000,
useDrafts = args.d || args.drafts || config.render_drafts || false,
loggerFormat = args.l || args.log,
@@ -84,11 +84,14 @@ module.exports = function(args, callback){
if (err) return callback(err);
// Start listening!
- app.listen(port, function(){
+ app.listen(port, serverIp, function(){
if (useDrafts)
log.i('Using drafts.');
-
- log.i('Hexo is running at ' + '%s:%d%s'.underline + '. Press Ctrl+C to stop.', serverAddress, port, root);
+
+ // for display purpose only
+ var ip = '';
+ (serverIp == '0.0.0.0') ? ip = 'localhost' : ip = serverIp;
+ log.i('Hexo is running at ' + 'http:\/\/%s:%d%s'.underline + '. Press Ctrl+C to stop.', ip, port, root);
/**
* Fired after server started.

0 comments on commit 6c6c554

Please sign in to comment.