Skip to content

Commit

Permalink
fix: use system timeout command with timeout helper
Browse files Browse the repository at this point in the history
  • Loading branch information
macite committed Aug 20, 2024
1 parent 38abe9e commit b77147c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 92 deletions.
10 changes: 4 additions & 6 deletions app/helpers/timeout_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ def try_within(sec, timeout_message = 'operation')
#
def system_try_within(sec, timeout_message, command)
# shell script to kill command after timeout
timeout_exec = Rails.root.join('lib/shell/timeout.sh')
result = false
try_within sec, timeout_message do
result = system "#{timeout_exec} -t #{sec} nice -n 10 #{command}"
end
result
system "timeout -k 2 #{sec} nice -n 10 #{command}"
rescue
logger.error "Timeout when #{timeout_message} after #{sec}s"
false
end

# Export functions as module functions
Expand Down
86 changes: 0 additions & 86 deletions lib/shell/timeout.sh

This file was deleted.

0 comments on commit b77147c

Please sign in to comment.