Class: Rubee::CLI::Server
- Inherits:
-
Object
- Object
- Rubee::CLI::Server
- Defined in:
- lib/rubee/cli/server.rb
Constant Summary collapse
- LOGO =
<<-'LOGO' ____ _ _ ____ _____ | _ \| | | || __ )| ____|_ | |_) | | | || _ \| _| _| | _ <| |__| || |_) | |___ _ |_| \_\\____/ |____/|_____|__| Ver: %s ⬡ ⬢ ⬢ rubee ⬢ ⬡ LOGO
Class Method Summary collapse
- .call(command, argv) ⇒ Object
- .jit_prefix(key) ⇒ Object
- .jit_prefix_dev(key) ⇒ Object
- .print_logo ⇒ Object
- .start(argv) ⇒ Object
- .start_dev(argv) ⇒ Object
- .status(_argv) ⇒ Object
- .stop(_argv) ⇒ Object
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 |
.print_logo ⇒ Object
54 55 56 |
# File 'lib/rubee/cli/server.rb', line 54 def print_logo 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 = argv.select { _1.start_with?('--') } port = .find { _1.start_with?('--port') }&.split('=')&.last jit = .find { _1.start_with?('--jit') }&.split('=')&.last port ||= '7000' print_logo 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) = argv.select { _1.start_with?('--') } port = .find { _1.start_with?('--port') }&.split('=')&.last jit = .find { _1.start_with?('--jit') }&.split('=')&.last port ||= '7000' print_logo 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 |