Class: Archsight::Web::Application
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Archsight::Web::Application
- Defined in:
- lib/archsight/web/application.rb
Constant Summary collapse
- RESTART_SHUTDOWN_DELAY =
begin Float(ENV.fetch("ARCHSIGHT_RESTART_SHUTDOWN_DELAY", "2.0")) rescue ArgumentError, TypeError 2.0 end
Class Attribute Summary collapse
-
.db ⇒ Object
Returns the value of attribute db.
Class Method Summary collapse
-
.configure_environment!(env, logging: nil) ⇒ Object
Configure application for the given environment.
- .database ⇒ Object
- .perform_restart! ⇒ Object
- .reload! ⇒ Object
-
.setup_mcp! ⇒ Object
MCP Server setup.
Class Attribute Details
.db ⇒ Object
Returns the value of attribute db.
25 26 27 |
# File 'lib/archsight/web/application.rb', line 25 def db @db end |
Class Method Details
.configure_environment!(env, logging: nil) ⇒ Object
Configure application for the given environment
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/archsight/web/application.rb', line 42 def configure_environment!(env, logging: nil) set :environment, env if env == :production set :quiet, true set :server_settings, { Silent: true } end # Determine logging: CLI override > env default (prod=true, dev=false) enable_logging = logging.nil? ? (env == :production) : logging use Rack::CommonLogger, $stdout if enable_logging end |
.database ⇒ Object
27 28 29 |
# File 'lib/archsight/web/application.rb', line 27 def database @database ||= Archsight::Database.new(Archsight.resources_dir).tap(&:reload!) end |
.perform_restart! ⇒ Object
226 227 228 229 230 231 |
# File 'lib/archsight/web/application.rb', line 226 def self.perform_restart! Thread.new do sleep RESTART_SHUTDOWN_DELAY if RESTART_SHUTDOWN_DELAY.positive? Process.kill("TERM", Process.pid) end end |
.reload! ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/archsight/web/application.rb', line 31 def reload! start = Time.new puts "== Reloading ..." if database.verbose database.reload! dur = (Time.new - start) * 1000 puts format("== done %0.2f ms", dur) if database.verbose end |
.setup_mcp! ⇒ Object
MCP Server setup
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/archsight/web/application.rb', line 73 def self.setup_mcp! mcp_server = FastMcp::Server.new( name: "Archsight MCP", version: Archsight::VERSION ) # Configure MCP tools with database Archsight::MCP.db = database mcp_server.register_tool(Archsight::MCP::QueryTool) mcp_server.register_tool(Archsight::MCP::AnalyzeResourceTool) mcp_server.register_tool(Archsight::MCP::ResourceDocTool) mcp_server.register_tool(Archsight::MCP::ExecuteAnalysisTool) use FastMcp::Transports::RackTransport, mcp_server, path_prefix: "/mcp", localhost_only: false end |