Skip to content

Commit

Permalink
Merge pull request #108 from ONLYOFFICE/fix/do-not-stop-delayed-runs
Browse files Browse the repository at this point in the history
Do not stop delayed runs thread in any cases
  • Loading branch information
ShockwaveNN committed Oct 14, 2015
2 parents 137ff85 + af6f0ed commit f4215e3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Add ability to show links, url and native html from parsed rspec results
* Add more info on server view page
* Add fetch ip button to server edit page
* Do not stop RunThreadManager in any cases. Always check for delayed runs
* Add default values for DelayedRuns view - each time

## 1.5.4.1
* Minor changes in internal logic of DelayedRun
Expand Down
2 changes: 1 addition & 1 deletion app/models/delayed_run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def should_start_by_time?(time_to_run)
run_datetime = time_to_run.to_time
if now.strftime('%d/%m/%y') == run_datetime.strftime('%d/%m/%y')
time_diff = (now - run_datetime).abs
Rails.logger.info "For delay run #{self} at #{time_to_run} time left #{time_diff} seconds"
Rails.logger.info "For delay run #{self} at #{time_to_run} time left #{(time_diff / 60).to_i} minutes"
(time_diff <= INFELICITY) || (run_datetime < now)
else
run_datetime < now
Expand Down
4 changes: 2 additions & 2 deletions app/views/delay_run/add_delayed_row.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
</select>
</div>
<div class="each-time" style="display: none; margin-left: 5px;">
<input class="hour form-control" placeholder="Hour" style="width: 32px;">
<input class="hour form-control" placeholder="Hour" style="width: 32px; " value="1">
:
<input class="min form-control" placeholder="Min" style="width: 32px;">
<input class="min form-control" placeholder="Min" style="width: 32px;" value="0">
</div>
<div class="save-delayed-run">
<i class="glyphicon glyphicon-floppy-disk"></i>
Expand Down
6 changes: 3 additions & 3 deletions app/workers/run_thread_manager.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module RunThreadManager
DAY_TIME = 24 * 60 * 60
WEEK_TIME = 7 * 24 * 60 * 60
CHECK_TIMEOUT = 60

def create_run_scan_thread
@run_scan_thread = Thread.new(caller: method(__method__).owner.to_s) do
loop do
Thread.stop if @runs.empty?
@runs.to_a.each do |run|
method_timing run
end
Rails.logger.info 'Waiting for next check for delay runner'
sleep 5
Rails.logger.info "Waiting for #{CHECK_TIMEOUT} seconds for next check for delay runs"
sleep CHECK_TIMEOUT
end
end
end
Expand Down

0 comments on commit f4215e3

Please sign in to comment.