Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Assume --skip-tail if the mongod we're connecting to is not a replset.

Print an informative warning, but then just do the import and exit
cleanly.

closes #10
  • Loading branch information...
commit 39722dbde98936f399bf52bed833744c1ccae374 1 parent dfce153
@nelhage nelhage authored
Showing with 13 additions and 8 deletions.
  1. +1 −1  Gemfile.lock
  2. +12 −7 lib/mosql/cli.rb
View
2  Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- mosql (0.1.1)
+ mosql (0.1.2)
bson_ext
json
log4r
View
19 lib/mosql/cli.rb
@@ -106,8 +106,11 @@ def parse_args
def connect_mongo
@mongo = Mongo::Connection.from_uri(options[:mongo])
config = @mongo['admin'].command(:ismaster => 1)
- if !config['setName']
- log.warn("`#{options[:mongo]}' is not a replset. Proceeding anyways...")
+ if !config['setName'] && !options[:skip_tail]
+ log.warn("`#{options[:mongo]}' is not a replset.")
+ log.warn("Will run the initial import, then stop.")
+ log.warn("Pass `--skip-tail' to suppress this warning.")
+ options[:skip_tail] = true
end
options[:service] ||= config['setName']
end
@@ -140,7 +143,9 @@ def run
initial_import
end
- optail
+ unless options[:skip_tail]
+ optail
+ end
end
# Helpers
@@ -189,7 +194,9 @@ def track_time
def initial_import
@schemamap.create_schema(@sql.db, !options[:no_drop_tables])
- start_ts = @mongo['local']['oplog.rs'].find_one({}, {:sort => [['$natural', -1]]})['ts']
+ unless options[:skip_tail]
+ start_ts = @mongo['local']['oplog.rs'].find_one({}, {:sort => [['$natural', -1]]})['ts']
+ end
want_dbs = @schemamap.all_mongo_dbs & @mongo.database_names
want_dbs.each do |dbname|
@@ -203,7 +210,7 @@ def initial_import
end
end
- tailer.write_timestamp(start_ts)
+ tailer.write_timestamp(start_ts) unless options[:skip_tail]
end
def import_collection(ns, collection)
@@ -240,8 +247,6 @@ def import_collection(ns, collection)
end
def optail
- return if options[:skip_tail]
-
tailer.tail_from(options[:tail_from] ?
BSON::Timestamp.new(options[:tail_from].to_i, 0) :
nil)
Please sign in to comment.
Something went wrong with that request. Please try again.