Class: Guard::PumaRunner
- Inherits:
-
Object
- Object
- Guard::PumaRunner
- Defined in:
- lib/guard/puma/runner.rb
Constant Summary collapse
- MAX_WAIT_COUNT =
20
Instance Attribute Summary collapse
-
#cmd_opts ⇒ Object
readonly
Returns the value of attribute cmd_opts.
-
#control_token ⇒ Object
readonly
Returns the value of attribute control_token.
-
#control_url ⇒ Object
readonly
Returns the value of attribute control_url.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#pumactl ⇒ Object
readonly
Returns the value of attribute pumactl.
Instance Method Summary collapse
- #halt ⇒ Object
-
#initialize(options) ⇒ PumaRunner
constructor
A new instance of PumaRunner.
- #restart ⇒ Object
- #sleep_time ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(options) ⇒ PumaRunner
Returns a new instance of PumaRunner.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/guard/puma/runner.rb', line 12 def initialize() @control_token = .delete(:control_token) { |_| ::Puma::Configuration.random_token } @control_port = (.delete(:control_port) || '9293') @control_url = "localhost:#{@control_port}" @quiet = .delete(:quiet) { true } @pumactl = .delete(:pumactl) { false } @options = = { (:config) => .fetch(:config, "-"), (:control_token) => @control_token, (:control_url) => "tcp://#{@control_url}" } if [:config] ['--config'] = [:config] elsif default_config_file_exists? ['--config'] = DEFAULT_CONFIG_FILE_PATH else ['--port'] = [:port] end %i[bind threads environment] .select { |opt| [opt] } .each do |opt| if pumactl Compat::UI.warning( "`#{opt}` option is not compatible with `pumactl` option" ) else ["--#{opt}"] = [opt] end end = .to_a.flatten << '--quiet' if @quiet @cmd_opts = .join ' ' end |
Instance Attribute Details
#cmd_opts ⇒ Object (readonly)
Returns the value of attribute cmd_opts.
10 11 12 |
# File 'lib/guard/puma/runner.rb', line 10 def cmd_opts @cmd_opts end |
#control_token ⇒ Object (readonly)
Returns the value of attribute control_token.
10 11 12 |
# File 'lib/guard/puma/runner.rb', line 10 def control_token @control_token end |
#control_url ⇒ Object (readonly)
Returns the value of attribute control_url.
10 11 12 |
# File 'lib/guard/puma/runner.rb', line 10 def control_url @control_url end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/guard/puma/runner.rb', line 10 def @options end |
#pumactl ⇒ Object (readonly)
Returns the value of attribute pumactl.
10 11 12 |
# File 'lib/guard/puma/runner.rb', line 10 def pumactl @pumactl end |
Instance Method Details
#halt ⇒ Object
52 53 54 55 56 |
# File 'lib/guard/puma/runner.rb', line 52 def halt run_puma_command!('halt') # server may not have been stopped correctly, but we are halting so who cares. return true end |
#restart ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/guard/puma/runner.rb', line 58 def restart if run_puma_command!('restart') return true else # server may not have been started correctly, or crashed. Let's try to start it. return start end end |
#sleep_time ⇒ Object
67 68 69 |
# File 'lib/guard/puma/runner.rb', line 67 def sleep_time [:timeout].to_f / MAX_WAIT_COUNT.to_f end |
#start ⇒ Object
48 49 50 |
# File 'lib/guard/puma/runner.rb', line 48 def start Kernel.system build_command('start') end |