Class: RSMP::CLI
- Inherits:
-
Thor
- Object
- Thor
- RSMP::CLI
- Defined in:
- lib/rsmp/cli.rb
Instance Method Summary collapse
Instance Method Details
#convert ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/rsmp/cli.rb', line 121 def convert unless [:in] puts "Error: Input option missing" exit end unless [:out] puts "Error: Output option missing" exit end unless File.exist? [:in] puts "Error: Input path file #{[:in]} not found" exit end sxl = RSMP::Convert::Import::YAML.read [:in] RSMP::Convert::Export::JSONSchema.write sxl, [:out] end |
#site ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rsmp/cli.rb', line 18 def site settings = {} log_settings = { 'active' => true } if [:config] if File.exist? [:config] settings = YAML.load_file [:config] log_settings = settings.delete('log') || {} else puts "Error: Config #{[:config]} not found" exit end end if [:id] settings['site_id'] = [:id] end if [:supervisors] settings['supervisors'] = [] [:supervisors].split(',').each do |supervisor| ip, port = supervisor.split ':' ip = '127.0.0.1' if ip.empty? port = '12111' if port.empty? settings['supervisors'] << {"ip"=>ip, "port"=>port} end end if [:log] log_settings['path'] = [:log] end if [:json] log_settings['json'] = [:json] end site_class = RSMP::Site if [:type] case [:type] when 'tlc' site_class = RSMP::TLC::TrafficControllerSite else site_class = RSMP::Site end end site_class.new(site_settings:settings, log_settings: log_settings).start rescue RSMP::Schemer::UnknownSchemaTypeError => e puts "Cannot start site: #{e}" rescue RSMP::Schemer::UnknownSchemaVersionError => e puts "Cannot start site: #{e}" rescue Psych::SyntaxError => e puts "Cannot read config file #{e}" end |
#supervisor ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/rsmp/cli.rb', line 79 def supervisor settings = {} log_settings = { 'active' => true } if [:config] if File.exist? [:config] settings = YAML.load_file [:config] log_settings = settings.delete 'log' else puts "Error: Config #{[:config]} not found" exit end end if [:id] settings['site_id'] = [:id] end if [:ip] settings['ip'] = [:ip] end if [:port] settings['port'] = [:port] end if [:log] log_settings['path'] = [:log] end if [:json] log_settings['json'] = [:json] end RSMP::Supervisor.new(supervisor_settings:settings,log_settings:log_settings).start rescue RSMP::ConfigurationError => e puts "Cannot start supervisor: #{e}" end |