Class: Gemkeeper::CLI::Commands::Server::Start

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

Instance Method Summary collapse

Instance Method Details

#call(**options) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/gemkeeper/cli/commands/server/start.rb', line 15

def call(**options)
  config = Configuration.load(options[:config])
  config = override_port(config, options[:port]) if options[:port]

  manager = ServerManager.new(config)

  if options[:foreground]
    puts "Starting Geminabox server at #{config.geminabox_url}"
    puts "Press Ctrl+C to stop"
    manager.start_foreground
  else
    manager.start
    puts "Geminabox server started at #{config.geminabox_url}"
    puts "PID: #{File.read(config.pid_file).strip}"
  end
rescue ServerAlreadyRunningError => e
  warn "Error: #{e.message}"
  exit 1
rescue ServerError => e
  warn "Error starting server: #{e.message}"
  exit 1
rescue Interrupt
  puts "\nShutting down..."
end