Class: AnyCable::CLI
- Inherits:
-
Object
- Object
- AnyCable::CLI
- Defined in:
- lib/anycable/cli.rb
Overview
Command-line interface for running AnyCable gRPC server rubocop:disable Metrics/ClassLength
Constant Summary collapse
- APP_CANDIDATES =
(not-so-big) List of common boot files for different applications
%w[ ./config/anycable.rb ./config/environment.rb ].freeze
- WAIT_PROCESS =
Wait for external process termination (s)
2
Instance Attribute Summary collapse
-
#health_server ⇒ Object
readonly
Returns the value of attribute health_server.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
-
#run(args) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
-
#shutdown ⇒ Object
rubocop:enable Metrics/AbcSize, Metrics/MethodLength.
Instance Attribute Details
#health_server ⇒ Object (readonly)
Returns the value of attribute health_server.
23 24 25 |
# File 'lib/anycable/cli.rb', line 23 def health_server @health_server end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
23 24 25 |
# File 'lib/anycable/cli.rb', line 23 def server @server end |
Instance Method Details
#run(args) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
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 71 72 73 74 75 76 77 |
# File 'lib/anycable/cli.rb', line 26 def run(args) @at_stop = [] = (args) # Boot app first, 'cause it might change # configuration, loggin settings, etc. boot_app! () logger.info "Starting AnyCable gRPC server (pid: #{Process.pid})" print_versions! logger.info "Serving #{defined?(::Rails) ? 'Rails ' : ''}application from #{boot_file}" configure_server! verify_connection_factory! log_grpc! if config.log_grpc log_errors! @server = AnyCable::Server.new( host: config.rpc_host, **config.to_grpc_params, interceptors: AnyCable.middleware.to_a ) # Make sure middlewares are not adding after server has started AnyCable.middleware.freeze start_health_server! if config.http_health_port_provided? start_pubsub! server.start run_custom_server_command! unless server_command.nil? begin wait_till_terminated rescue Interrupt => e logger.info "Stopping... #{e.}" shutdown logger.info "Stopped. Good-bye!" exit(0) end end |
#shutdown ⇒ Object
rubocop:enable Metrics/AbcSize, Metrics/MethodLength
80 81 82 83 |
# File 'lib/anycable/cli.rb', line 80 def shutdown at_stop.each(&:call) server.stop end |