Class: Rsodx::Cli::Commands::Server

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/rsodx/cli/commands/server.rb

Instance Method Summary collapse

Instance Method Details

#call(args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rsodx/cli/commands/server.rb', line 10

def call(args)
  env = args[:env]
  port = args[:port]
  ENV["RACK_ENV"] = env

  rackup_path = File.expand_path("config.ru", Dir.pwd)
  unless File.exist?(rackup_path)
    abort "❌ config.ru not found in #{Dir.pwd}"
  end

  pid = spawn("bundle exec rackup --port=#{port} --host=0.0.0.0 #{rackup_path}")
  puts "🚀 Rsodx started!"
  Process.wait(pid)
rescue => e
  abort "❌ Failed to start server: #{e.class} - #{e.message}"
end