Don't forget to lycansubscribe
at master 870 B view raw
1#!/usr/bin/env ruby 2 3$LOAD_PATH.unshift(File.expand_path('..', __dir__)) 4 5require 'bundler/setup' 6require 'app/firehose_client' 7 8$stdout.sync = true 9 10if ENV['ARLOG'] == '1' 11 ActiveRecord::Base.logger = Logger.new(STDOUT) 12else 13 ActiveRecord::Base.logger = nil 14end 15 16def print_help 17 puts "Usage: #{$0} [options...]" 18 puts "Options:" 19 puts " -r12345 = start from cursor 12345" 20end 21 22firehose = FirehoseClient.new 23 24args = ARGV.dup 25 26while arg = args.shift 27 case arg 28 when /^\-r(\d+)$/ 29 firehose.start_cursor = $1.to_i 30 when '-h', '--help' 31 print_help 32 exit 0 33 else 34 puts "Unrecognized option: #{arg}" 35 print_help 36 exit 1 37 end 38end 39 40trap("SIGINT") { 41 firehose.log "Stopping..." 42 43 EM.add_timer(0) { 44 firehose.stop 45 } 46} 47 48trap("SIGTERM") { 49 firehose.log "Shutting down the service..." 50 51 EM.add_timer(0) { 52 firehose.stop 53 } 54} 55 56firehose.start