From Rails, I make a wget system call:
wget
system("wget", ...)
I want to set a timeout for this call, so if it takes too much time (which probably means too many uploaded files or a large file uploaded), I want to stop it and return an error to the user so that my server is not overloaded . How can i do this?
Need to make a call in a subarea? If not, use timeout and callbacks:
require 'timeout' Timeout.timeout(3) do puts `tree /` # raises an exception, which you can rescue and handle end
If you need to run it from the outside, I would go with something like Subexec
In general, try wrapping the call in SystemTimer. https://rubygems.org/gems/SystemTimer
In your specific case, try system("wget -T #{timeout_in_seconds}")
system("wget -T #{timeout_in_seconds}")
Source: https://habr.com/ru/post/1479250/More articles:Spring Security Authorization. Administrator denied access. - springDragging text into text box - jqueryRemove div shell from hidden rails - ruby-on-railsHow to integrate Pay with card strip in backbonejs - node.jsed.onKeyDown in tinymce example - javascripthow to add underline to certain asp.net button text words - asp.netGetting encoding = "UTF-8" standalone = "yes" using PHP asXML and SimpleXMLElement - xmlJQuery switches text by click - jqueryActive Admin has_many with a set number of nested relationships - ruby-on-railsXcode 4.2 command line tools - osx-snow-leopardAll Articles