Add support for backing off attempts to start applications that continuously
[mod_fastcgi.git] / mod_fastcgi.h
blob0c1df10ca2b0e0efc83c2d3a84fc19046bfd21d3
1 /*
2 * $Id: mod_fastcgi.h,v 1.41 2002/02/28 22:52:50 robs Exp $
3 */
5 #ifndef MOD_FASTCGI_H
6 #define MOD_FASTCGI_H
8 #define MOD_FASTCGI_VERSION "2.2.13"
11 * # of idle seconds allowed to pass while connected to a FastCGI before aborting
13 #define FCGI_DEFAULT_IDLE_TIMEOUT 30
16 * (WIN32) # of sec to wait while trying to connect using a named pipe.
17 * This is overridden by -appConnTimeout, if set. This value is similiar
18 * to the OS specific (blocking) connect() timeout. According to XXX
19 * this is typically XXX sec.
21 #define FCGI_NAMED_PIPE_CONNECT_TIMEOUT 90
23 /*
24 * [WIN32] The number of millisecs to wait after having signaled the
25 * termination event to its applications before issuing a TerminateProcess().
26 * If all of the applications are based on a version of the FastCGI
27 * application library that properly handles the shutdown event
28 * (fcgi2 v2.2.4), this can be set to <= 0 to prevent the use of
29 * TerminateProcess() entirely. If non of the applications support the
30 * termination event, this value can be set to 1. It is highly reccomended
31 * that the termination event be supported, as TerminateProcess() is a
32 * brutal way of taking down an application.
34 #define WIN32_SHUTDOWN_GRACEFUL_WAIT 1000
37 * The number of failed starts that can occur before the application is
38 * considered broken and start attempts fall back to FAILED_STARTS_DELAY.
40 #define MAX_FAILED_STARTS 3
43 * The number of seconds an application has to have run without exiting
44 * for the application to be considered no longer broken.
46 #define RUNTIME_SUCCESS_INTERVAL 30
49 * The number of seconds between attempts to start an application that
50 * has been declared broken (see MAX_FAILED_STARTS).
52 #define FAILED_STARTS_DELAY 600
54 #define FCGI_DEFAULT_LISTEN_Q 100 /* listen queue (backlog) depth */
55 #define FCGI_DEFAULT_RESTART_DELAY 5 /* delay between restarts */
56 #define DEFAULT_INIT_START_DELAY 1 /* delay between starts */
57 #define FCGI_DEFAULT_PRIORITY 0 /* process priority - not used */
58 #define FCGI_MIN_EXEC_RETRY_DELAY 10 /* minimum number of seconds to
59 wait before restarting */
60 #define MAX_INIT_ENV_VARS 64 /* max # of -initial-env options */
62 /* max number of chars in a line of stderr we can handle from a FastCGI Server */
63 #define FCGI_SERVER_MAX_STDERR_LINE_LEN 1023
65 /* size of the buffer the PM uses to read records from the request handlers */
66 #define FCGI_MSGS_BUFSIZE 32 * 512
68 #define SERVER_BUFSIZE 8192
70 /* Dynamic FastCGI applications */
71 #define FCGI_DEFAULT_MAX_PROCS 50 /* maximum number of processes that
72 * are allowed to run on system */
73 #define FCGI_DEFAULT_MIN_PROCS 5 /* minimum number of processes that
74 * can be run without being killed
75 * off by the process manager */
76 #define FCGI_DEFAULT_MAX_CLASS_PROCS 10 /* maximum number of processes that
77 * are allowed to run for a single
78 * application class */
79 #define FCGI_DEFAULT_KILL_INTERVAL 300 /* number of seconds in which we
80 * should execute the kill policy
81 * by killing off extra instances */
82 #define FCGI_DEFAULT_UPDATE_INTERVAL 300 /* number of seconds in which we
83 * should recalculate the value of
84 * totalConnTime variable */
85 #define FCGI_DEFAULT_GAIN 0.5 /* value used as an exponent in the
86 * calculation of the exponentially
87 * decayed connection times;
88 * old values are scaled by
89 * (1-dynamicGain), so making it
90 * smaller weights them more heavily
91 * compared to the current value,
92 * which is scaled by dynamicGain */
93 #define FCGI_DEFAULT_THRESHOLD_1 0 /* if load falls below this value
94 * and we have only one instance
95 * running, it is killed off */
96 #define FCGI_DEFAULT_THRESHOLD_N 50 /* if load falls below this value
97 * and we have more than one
98 * instances, one is killed off */
99 #define FCGI_DEFAULT_START_PROCESS_DELAY 3 /* specifies the maximum number of
100 * seconds a server should wait in
101 * attempt to connect to fcgi app
102 * before sending FCGI_REQUEST_TIMEOUT_JOB */
105 * # of sec to wait in a non-blocking connect() to the FastCGI application
106 * before aborting the request, or 0 to indicate that blocking connect()s
107 * should be used. Non-blocking connect()s are problematic on many platforms.
109 #define FCGI_DEFAULT_APP_CONN_TIMEOUT 0
111 #define FCGI_DEFAULT_PROCESS_SLACK 5 /* if this number combined with the
112 * number of the currently running
113 * processes exceeds dynamicMaxProcs, then
114 * the KillDynamicProcs() is invoked */
115 #define FCGI_DEFAULT_RESTART_DYNAMIC 0 /* Do not restart dynamic processes */
116 #define FCGI_DEFAULT_AUTOUPDATE 0 /* do not automatically restart
117 * fcgi apps when the binary on the
118 * disk is changed. */
121 * Should data recieved from the FastCGI server be immediately flushed to
122 * the client? Default: FALSE
124 #define FCGI_FLUSH FALSE
126 #ifdef WIN32
128 /* # of millisecs to wait on the mbox mutex */
129 #define FCGI_MBOX_MUTEX_TIMEOUT 5000
131 #define DEFAULT_SOCK_DIR "\\\\.\\pipe\\FastCGI\\"
133 #else /* ! WIN32 */
135 #define DEFAULT_SOCK_DIR "/tmp/fcgi" /* Default dir for Unix/Domain sockets */
137 #endif /* ! WIN32 */
139 #define FCGI_MAGIC_TYPE "application/x-httpd-fcgi"
141 #if defined(PATH_MAX)
142 #define FCGI_MAXPATH PATH_MAX
143 #elif defined(MAXPATHLEN)
144 #define FCGI_MAXPATH MAXPATHLEN
145 #else
146 #define FCGI_MAXPATH 512
147 #endif
149 /* FCGI_REQUEST_COMPLETE_JOB is the longest: id, path, user, gid, qtime, start */
150 #define FCGI_MSG_CRAP 1 + 2 + MAX_USER_NAME_LEN + 1 + MAX_GID_CHAR_LEN + (2 * 11) + 3
152 #if defined(PIPE_BUF) && PIPE_BUF < FCGI_MAXPATH + FCGI_MSG_CRAP
153 #define FCGI_MAX_MSG_LEN PIPE_BUF
154 #undef FCGI_MAXPATH
155 #define FCGI_MAXPATH PIPE_BUF - FCGI_MSG_CRAP
156 #else
157 #define FCGI_MAX_MSG_LEN FCGI_MAXPATH + FCGI_MSG_CRAP
158 #endif
160 /* There is no way to reliably determiine the highest descriptor that can be
161 * assigned (UNP Vol1 Ed2 p337, and APUE p43) so we pick a number. */
162 #if (defined FD_SETSIZE) && (FD_SETSIZE > 1024)
163 #define FCGI_MAX_FD FD_SETSIZE
164 #else
165 #define FCGI_MAX_FD 1024
166 #endif
168 #ifndef SUN_LEN
169 #define SUN_LEN(sock) \
170 (sizeof(*(sock)) - sizeof((sock)->sun_path) + strlen((sock)->sun_path))
171 #endif
173 #if defined MAXLOGNAME && MAXLOGNAME > 15
174 #define MAX_USER_NAME_LEN MAXLOGNAME
175 #elif defined UT_NAMESIZE && UT_NAMESIZE > 15
176 #define MAX_USER_NAME_LEN UT_NAMESIZE
177 #else
178 #define MAX_USER_NAME_LEN 15 /* Max len of user name (suexec w/ ~user), */
179 #endif /* must accomodate uid printed as %ld too */
180 #define MAX_GID_CHAR_LEN 15 /* Max #chars in a gid printed as %ld */
182 #ifndef TRUE
183 #define TRUE (1)
184 #endif
186 #ifndef FALSE
187 #define FALSE (0)
188 #endif
190 #ifndef min
191 #define min(a,b) ((a) < (b) ? (a) : (b))
192 #endif
194 #ifndef max
195 #define max(a,b) ((a) > (b) ? (a) : (b))
196 #endif
198 /* This is (more or less) from http_main.c. It should be in an Apache header */
199 #ifndef SYS_SIGLIST
200 #define SYS_SIGLIST ap_sys_siglist
201 extern const char *ap_sys_siglist[];
202 #endif
204 #endif /* MOD_FASTCGI_H */