diff options
-rw-r--r-- | shell/mongo.js | 60 | ||||
-rw-r--r-- | shell/servers.js | 61 |
2 files changed, 61 insertions, 60 deletions
diff --git a/shell/mongo.js b/shell/mongo.js index 350ca8381ca..50e8ae1aec5 100644 --- a/shell/mongo.js +++ b/shell/mongo.js @@ -63,63 +63,3 @@ connect = function( url , user , pass ){ return db; } - -_parsePath = function() { - var dbpath = ""; - for( var i = 0; i < arguments.length; ++i ) - if ( arguments[ i ] == "--dbpath" ) - dbpath = arguments[ i + 1 ]; - - if ( dbpath == "" ) - throw "No dbpath specified"; - - return dbpath; -} - -_parsePort = function() { - var port = ""; - for( var i = 0; i < arguments.length; ++i ) - if ( arguments[ i ] == "--port" ) - port = arguments[ i + 1 ]; - - if ( port == "" ) - throw "No port specified"; - return port; -} - -// Start a mongod instance and return a 'Mongo' object connected to it. -// This function's arguments are passed as command line arguments to mongod. -// The specified 'dbpath' is cleared if it exists, created if not. -startMongod = function() { - var dbpath = _parsePath.apply( null, arguments ); - resetDbpath( dbpath ); - var fullArgs = Array(); - fullArgs[ 0 ] = "mongod"; - for( i = 0; i < arguments.length; ++i ) - fullArgs[ i + 1 ] = arguments[ i ]; - return startMongoProgram.apply( null, fullArgs ); -} - -// Start a mongo program instance (generally mongod or mongos) and return a -// 'Mongo' object connected to it. This function's first argument is the -// program name, and subsequent arguments to this function are passed as -// command line arguments to the program. -startMongoProgram = function() { - var port = _parsePort.apply( null, arguments ); - - _startMongoProgram.apply( null, arguments ); - - var m; - assert.soon - ( function() { - try { - m = new Mongo( "127.0.0.1:" + port ); - return true; - } catch( e ) { - } - return false; - } ); - - return m; -} - diff --git a/shell/servers.js b/shell/servers.js new file mode 100644 index 00000000000..ae8f5665b2e --- /dev/null +++ b/shell/servers.js @@ -0,0 +1,61 @@ + + +_parsePath = function() { + var dbpath = ""; + for( var i = 0; i < arguments.length; ++i ) + if ( arguments[ i ] == "--dbpath" ) + dbpath = arguments[ i + 1 ]; + + if ( dbpath == "" ) + throw "No dbpath specified"; + + return dbpath; +} + +_parsePort = function() { + var port = ""; + for( var i = 0; i < arguments.length; ++i ) + if ( arguments[ i ] == "--port" ) + port = arguments[ i + 1 ]; + + if ( port == "" ) + throw "No port specified"; + return port; +} + +// Start a mongod instance and return a 'Mongo' object connected to it. +// This function's arguments are passed as command line arguments to mongod. +// The specified 'dbpath' is cleared if it exists, created if not. +startMongod = function() { + var dbpath = _parsePath.apply( null, arguments ); + resetDbpath( dbpath ); + var fullArgs = Array(); + fullArgs[ 0 ] = "mongod"; + for( i = 0; i < arguments.length; ++i ) + fullArgs[ i + 1 ] = arguments[ i ]; + return startMongoProgram.apply( null, fullArgs ); +} + +// Start a mongo program instance (generally mongod or mongos) and return a +// 'Mongo' object connected to it. This function's first argument is the +// program name, and subsequent arguments to this function are passed as +// command line arguments to the program. +startMongoProgram = function() { + var port = _parsePort.apply( null, arguments ); + + _startMongoProgram.apply( null, arguments ); + + var m; + assert.soon + ( function() { + try { + m = new Mongo( "127.0.0.1:" + port ); + return true; + } catch( e ) { + } + return false; + } ); + + return m; +} + |