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
fix: removed identical jit_prefix_dev; use this for both.
- .print_logo ⇒ Object
- .start(argv) ⇒ Object
- .start_dev(argv) ⇒ Object
- .status(_argv) ⇒ Object
- .stop(_argv) ⇒ Object
Class Method Details
.call(command, argv) ⇒ Object
13 14 15 |
# File 'lib/rubee/cli/server.rb', line 13 def call(command, argv) send(command, argv) end |
.jit_prefix(key) ⇒ Object
fix: removed identical jit_prefix_dev; use this for both
67 68 69 70 71 72 |
# File 'lib/rubee/cli/server.rb', line 67 def jit_prefix(key) # fix: removed identical jit_prefix_dev; use this for both case key when 'yjit' then "ruby --yjit -S " else "" end end |
.print_logo ⇒ Object
63 64 65 |
# File 'lib/rubee/cli/server.rb', line 63 def print_logo puts "\e[36m#{LOGO % Rubee::VERSION}\e[0m" end |
.start(argv) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rubee/cli/server.rb', line 17 def start(argv) = argv.select { _1.start_with?('--') } port = .find { _1.start_with?('--port') }&.split('=')&.last jit = .find { _1.start_with?('--jit') }&.split('=')&.last port ||= ENV.fetch('PORT', '7000') # fix: don't clobber parsed port puma_config = ENV.fetch('PUMA_CONFIG', 'config/puma.rb') rackup_file = ENV.fetch('RACKUP_FILE', '') print_logo color_puts("Starting takeoff of ruBee on port: #{port}...", color: :yellow) command = [ jit_prefix(jit), "bundle exec puma", File.exist?(puma_config) ? "-C #{puma_config}" : '', rackup_file, "-p #{port}", ].join(" ") color_puts(command, color: :gray) exec(command) end |
.start_dev(argv) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rubee/cli/server.rb', line 40 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 ||= ENV.fetch('PORT', '7000') # fix: consistent with start; use ENV fallback rackup_file = ENV.fetch('RACKUP_FILE', '') print_logo color_puts("Starting takeoff of ruBee server on port #{port} in dev mode...", color: :yellow) command = "rerun -- #{jit_prefix(jit)}rackup --port #{port} #{rackup_file}" color_puts(command, color: :gray) exec(command) end |
.status(_argv) ⇒ Object
59 60 61 |
# File 'lib/rubee/cli/server.rb', line 59 def status(_argv) exec('ps aux | grep rubee') end |
.stop(_argv) ⇒ Object
55 56 57 |
# File 'lib/rubee/cli/server.rb', line 55 def stop(_argv) exec('pkill -f rubee') end |