6696987406845625c252a13b690e0c4d7d9e59fa max Thu Mar 26 06:48:48 2015 -0700 This is a go at libifing the CGI startup code. For all CGIs, we need to call a few basic setup funtions, like UDC config and CGI apoptosis. (For most CGIs also bottleneck). Instead of adding it to all of our 30+ CGIs, I changed the cart*Shell functions. I think most CGIs call at least one of these functions. This commit removes the existing copy/pasted code from a few CGIs and replaces it with one call. Adding this to the cart-setup means that (like before), UDC is setup even for small JSON calls and a process is spawned to watch the CGI and kill it ("Apoptosis"). Any comments on whether this should be implemented differently are appreciated. I have not added bottleneck to this function right now as apparently we're calling bottleneck only from some of our CGIs. diff --git src/hg/lib/hCommon.c src/hg/lib/hCommon.c index 04354c2..a8202c6 100644 --- src/hg/lib/hCommon.c +++ src/hg/lib/hCommon.c @@ -1,26 +1,31 @@ /* hCommon.c - routines used by many files in hgap project. */ /* Copyright (C) 2014 The Regents of the University of California * See README in this or parent directory for licensing information. */ #include "common.h" #include "hCommon.h" #include "chromInfo.h" #include "portable.h" #include "hgConfig.h" #include "errAbort.h" +#include "cgiApoptosis.h" +#include "udc.h" +#include "knetUdc.h" +#include "hui.h" +#include "cart.h" static char *_hgcName = "../cgi-bin/hgc"; /* Path to click processing program. */ static char *_hgTracksName = "../cgi-bin/hgTracks"; /* Path back to genome browser. */ static char *_hgTrackUiName = "../cgi-bin/hgTrackUi"; /* Path to extended ui program. */ static char *_hgFileUiName = "../cgi-bin/hgFileUi"; /* Path to downloladable files CGI. */ static char *_hgTextName = "../cgi-bin/hgText"; /* Path back to the text browser. */ static char *_hgTablesName = "../cgi-bin/hgTables"; /* Path back to the table browser. */ static char *_hgVaiName = "../cgi-bin/hgVai"; /* Path back to the variant annotation integrator. */ static char *_hgCustomName = "../cgi-bin/hgCustom"; /* Path back to the custom tracks manager. */ static char *_hgHubConnectName = "../cgi-bin/hgHubConnect"; /* Path back to the track hub manager. */ static char *_hgSessionName = "../cgi-bin/hgSession"; /* Path to session manager. */ static char *_hgPalName = "../cgi-bin/hgPal"; /* Path back to the protein aligner */ static char *_hgVarAnnogratorName = "../cgi-bin/hgVarAnnogrator"; /* Path to variant annot intgr */ static char *_hgIntegratorName = "../cgi-bin/hgIntegrator"; /* Path to annotation intgrator */ @@ -370,15 +375,39 @@ void hUserAbort(char *format, ...) /* errAbort when a `user' error is detected. This is an error that comes * from user input. This disables the logging stack dumps. */ { va_list args; va_start(args, format); hVaUserAbort(format, args); va_end(args); } boolean hAllowAllTables(void) /* Return TRUE if hg.conf's hgta.disableAllTables doesn't forbid an 'all tables' menu. */ { return !cfgOptionBooleanDefault("hgta.disableAllTables", FALSE); } + +void hCgiStartSetup(struct cart *cart) +/* should be called at the start of the CGI */ +/* do the CGI setup operations: CGI apoptosis, UDC setup etc */ +/* cart parameter can be NULL */ +/* is not in cart.c as it can be called from parts of the code that + * do not need a cart */ +{ +static bool setupDone = FALSE; +if (setupDone) + return; +setupDone = TRUE; + +cgiApoptosisSetup(); + +knetUdcInstall(); +setUdcCacheDir(); + +if (cart==NULL) + udcSetCacheTimeout(300); +else + setUdcTimeout(cart); + +}