add rate setting

This commit is contained in:
邱博亞 2023-04-23 17:27:04 +08:00
parent 6b84921f59
commit f0df2fac26
3 changed files with 11 additions and 2 deletions

View File

@ -33,12 +33,13 @@ class Admin::PlowController < OrbitAdminController
host = uri.host host = uri.host
ip = @setting.ip ip = @setting.ip
concurrent = @setting.concurrent concurrent = @setting.concurrent
rate = @setting.rate
scheme = uri.scheme scheme = uri.scheme
Thread.new do Thread.new do
if !ip.blank? if !ip.blank?
`ulimit -n 100000 && #{Binary} #{scheme}://#{ip}#{uri.request_uri} --host=#{host} --listen=#{SocketFile} -c#{concurrent} --summary > #{LogFile}` `ulimit -n 100000 && #{Binary} #{scheme}://#{ip}#{uri.request_uri} --host=#{host} --listen=#{SocketFile} -c#{concurrent} --rate #{rate} --summary > #{LogFile}`
else else
`ulimit -n 100000 && #{Binary} #{@setting.url} --listen=#{SocketFile} -c#{concurrent} --summary > #{LogFile}` `ulimit -n 100000 && #{Binary} #{@setting.url} --listen=#{SocketFile} -c#{concurrent} --rate #{rate} --summary > #{LogFile}`
end end
end end
max_wait = 10 max_wait = 10

View File

@ -5,4 +5,5 @@ class PlowSetting
field :concurrent, type: Integer, :default => 1 field :concurrent, type: Integer, :default => 1
field :ip, type: String field :ip, type: String
field :url, type: String field :url, type: String
field :rate, type: Integer, :default => 5000
end end

View File

@ -25,6 +25,13 @@
</div> </div>
</div> </div>
<div class="control-group">
<label class="control-label muted" for="rate">Request Rate(Requests/seconds)</label>
<div class="controls">
<%= f.number_field :rate, :class => 'input-large' %>
</div>
</div>
<% if !@logContent.blank? %> <% if !@logContent.blank? %>
<div class="control-group"> <div class="control-group">
<label class="control-label muted">Summary</label> <label class="control-label muted">Summary</label>