Class: Rubee::CLI::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/rubee/cli/server.rb

Constant Summary collapse

LOGO =
<<-'LOGO'
  ____  _    _  ____  _____
 |  _ \| |  | || __ )| ____|_
 | |_) | |  | ||  _ \|  _|  _|
 |  _ <| |__| || |_) | |___ _
 |_| \_\\____/ |____/|_____|__|
 Ver: %s       ⬡ ⬢ ⬢ rubee ⬢ ⬡
LOGO

Class Method Summary collapse

Class Method Details

.call(command, argv) ⇒ Object



14
15
16
# File 'lib/rubee/cli/server.rb', line 14

def call(command, argv)
  send(command, argv)
end

.jit_prefix(key) ⇒ Object



58
59
60
61
62
63
64
65
# File 'lib/rubee/cli/server.rb', line 58

def jit_prefix(key)
  case key
  when 'yjit'
    "ruby --yjit -S "
  else
    ""
  end
end

.jit_prefix_dev(key) ⇒ Object



67
68
69
70
71
72
73
74
# File 'lib/rubee/cli/server.rb', line 67

def jit_prefix_dev(key)
  case key
  when 'yjit'
    "ruby --yjit -S "
  else
    ""
  end
end


54
55
56
# File 'lib/rubee/cli/server.rb', line 54

def 
  puts "\e[36m#{LOGO % Rubee::VERSION}\e[0m" # Cyan color
end

.start(argv) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rubee/cli/server.rb', line 18

def start(argv)
  # get params
  options = argv.select { _1.start_with?('--') }
  port = options.find { _1.start_with?('--port') }&.split('=')&.last
  jit = options.find { _1.start_with?('--jit') }&.split('=')&.last

  port ||= '7000'
  
  color_puts("Starting takeoff of ruBee on port: #{port}...", color: :yellow)
  command = "#{jit_prefix(jit)}rackup #{ENV['RACKUP_FILE']} -p #{port}"
  color_puts(command, color: :gray)
  exec(command)
end

.start_dev(argv) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rubee/cli/server.rb', line 32

def start_dev(argv)
  options = argv.select { _1.start_with?('--') }
  port = options.find { _1.start_with?('--port') }&.split('=')&.last
  jit = options.find { _1.start_with?('--jit') }&.split('=')&.last

  port ||= '7000'
  

  color_puts("Starting takeoff of ruBee server on port #{port} in dev mode...", color: :yellow)
  command = "rerun -- #{jit_prefix_dev(jit)}rackup --port #{port} #{ENV['RACKUP_FILE']}"
  color_puts(command, color: :gray)
  exec(command)
end

.status(_argv) ⇒ Object



50
51
52
# File 'lib/rubee/cli/server.rb', line 50

def status(_argv)
  exec('ps aux | grep rubee')
end

.stop(_argv) ⇒ Object



46
47
48
# File 'lib/rubee/cli/server.rb', line 46

def stop(_argv)
  exec('pkill -f rubee')
end