cf913e42c14bc753f3575fffebcd417d2df3ea70
max
  Thu Nov 14 07:50:43 2024 -0800
making sure that hgGeneGraph is not spawning more and more dot programs. This came up because on Nov 14 today, a lot of stuck dot programs were running on the RR. The root problem may have been something else, but this should make hgGeneGraph a little less problematic in the future. Also, we can use hg.conf now to constrain dot programs more. no redmine

diff --git src/hg/hgGeneGraph/hgGeneGraph src/hg/hgGeneGraph/hgGeneGraph
index dbaed72..b90474a 100755
--- src/hg/hgGeneGraph/hgGeneGraph
+++ src/hg/hgGeneGraph/hgGeneGraph
@@ -638,38 +638,47 @@
         see findDot()
     """
     outFname = splitext(fname)[0]+"."+format
     outMap = splitext(fname)[0]+".map"
 
     binPath = findDot()
 
     if which(binPath) is None:
         print("Could not find the command dot or cgi-bin/loader/dot_static<p>")
         printDotErrorHelpAndExit()
 
     # work around a dot message that clutters our apache logs on some redhats
     # https://stackoverflow.com/questions/29809462/uncss-error-c-utf-8-not-a-valid-language-tag
     os.environ["LC_ALL"] = "en_US.utf8"
 
-    cmd = [binPath, "-Gdpi=96", "-Gsize=12,5", "-Gratio=fill", "-K"+alg, "-T"+format, fname, "-o",outFname, "-q 2"]
+    # when the RR is overloaded due to bot activity, make sure that stuck dot programs do not accumulate and clog the server even more 
+    # but have them stop at some point
+    dotTimeout = cfgOption("dotTimeout", "20s")
+
+    # it seems that "timeout" is installed on all our own servers 
+    cmd = ["timeout", dotTimeout, binPath, "-Gdpi=96", "-Gsize=12,5", "-Gratio=fill", "-K"+alg, "-T"+format, fname, "-o",outFname, "-q 2"]
     # create a html map for png format
     if format=="png":
         cmd.extend(["-Tcmapx", "-o", outMap])
     ret = runCmd(cmd, mustRun=False)
 
     if ret!=0:
-        print(("Could not run the command '%s'. <p>" % " ".join(cmd)))
+        if ret==124:
+            print("Error %d: The gene graph took too long to build. Please contact us." % ret)
+            sys.exit(0)
+        else:
+            print(("Error %d: Could not run the command '%s'. <p>" % (ret, " ".join(cmd))))
             printDotErrorHelpAndExit()
 
     return outFname, outMap
 
 def dictToDot(d):
     """ reformat a dictionary to a string like [key1="value1"; key2="value2"] """
     if len(d)==0:
         return ""
 
     strList = []
     for key, val in d.items():
         strList.append('%s="%s"' % (key, val.replace('"', '')))
     return "[%s]" % (";".join(strList))
 
 def writeDot(allGenes, links, fname, targetGene, geneDescs, annotLabel, geneAnnots, linkSnips):