Class: Legate::CLI::WebCommands
- Inherits:
-
BaseCommand
- Object
- Thor
- BaseCommand
- Legate::CLI::WebCommands
- Defined in:
- lib/legate/cli/web_commands.rb
Overview
CLI commands for web interface
Constant Summary collapse
- TOOL_DIRECTORIES =
Conventional directories to scan for custom tools and agents
[ 'lib/tools', 'agents/lib/tools', 'tools' ].freeze
- AGENT_DIRECTORIES =
[ 'lib/agents', 'agents/lib/agents', 'agents' ].freeze
- INIT_FILES =
Optional initializer file that runs before auto-loading
[ 'legate_init.rb', 'config/legate_init.rb', 'agents/legate_init.rb' ].freeze
Instance Method Summary collapse
Methods inherited from BaseCommand
Instance Method Details
#start ⇒ Object
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 78 79 80 81 |
# File 'lib/legate/cli/web_commands.rb', line 37 def start # Auto-load custom tools and agents unless disabled unless [:no_autoload] load_custom_initializer load_custom_tools load_custom_agents end # Access config early webhook_config = Legate.config.webhooks listener_enabled = webhook_config.listener_enabled listener_base_path = webhook_config.base_path # Build the Rack application stack app = Rack::Builder.new do # Conditionally mount the Webhook Listener if listener_enabled Legate.logger.info "Webhook listener enabled, mounting at #{listener_base_path}" begin require_relative '../web/webhook_listener' map listener_base_path do run Legate::Web::WebhookListener.new end rescue LoadError => e Legate.logger.error "Failed to load WebhookListener: #{e.}. Listener will not be mounted." rescue StandardError => e Legate.logger.error "Error initializing WebhookListener: #{e.}. Listener will not be mounted." end else Legate.logger.debug 'Webhook listener is disabled.' end # Mount the main Legate Web App at the root run Legate::Web::App.new end.to_app # Convert builder block to a Rack app # Start the server using Rack::Handler::Puma (Rack 2.x compatible) say "Starting Legate web interface on http://#{[:host]}:#{[:port]}" Rack::Handler::Puma.run( app, Host: [:host], Port: [:port], Silent: false ) end |