wurmlab / sequenceserver

Intuitive graphical web interface for running BLAST bioinformatics tool (i.e. have your own custom NCBI BLAST site!)
https://sequenceserver.com
GNU Affero General Public License v3.0
268 stars 111 forks source link

Support optional job timeout #770

Open nathanweeks opened 1 month ago

nathanweeks commented 1 month ago

To prevent runaway blast jobs from blocking a sequenceserver instance, it would be helpful to support an optional/configurable job timeout with descriptive error message in the event of a timeout.

As a stopgap, a user might hard-code a CPU time limit:

--- a/lib/sequenceserver/sys.rb
+++ b/lib/sequenceserver/sys.rb
@@ -45,6 +45,8 @@ module SequenceServer
       # Change to the specified directory.
       Dir.chdir(options[:dir]) if options[:dir] && Dir.exist?(options[:dir])

+      Process::setrlimit(:CPU, 300) # 5-minute timeout
+
       # Execute the shell command, redirect stdout and stderr to the
       # temporary files.
       exec(command, out: temp_files[:stdout].path.to_s, \

Though in the event of a timeout, the resulting error message is misleading at best ("BLAST query/options error: Invalid input format for BLAST Archive. Please refer to the BLAST+ user manual."), and a wall-time limit would be preferable---perhaps with the timeout module?