|
@@ -19,6 +19,9 @@
|
19
|
19
|
#ifndef __CONF_H___
|
20
|
20
|
#define __CONF_H___
|
21
|
21
|
|
|
22
|
+#include <unistd.h>
|
|
23
|
+#include <getopt.h>
|
|
24
|
+
|
22
|
25
|
#include "config.h"
|
23
|
26
|
/**@defgroup conf_internal PYFCGI configuration handling
|
24
|
27
|
*/
|
|
@@ -38,6 +41,55 @@
|
38
|
41
|
/**@ingroup ret_status */
|
39
|
42
|
#define PYFCGI_FATAL 128
|
40
|
43
|
|
|
44
|
+#define PYFCGI_NAME "spawn-fcgi [OPTIONS] -- pyfcgi"
|
|
45
|
+
|
|
46
|
+#define PYFCGI_SHORT_OPT "Ce:E:w:W:m:l:Svh"
|
|
47
|
+
|
|
48
|
+#define PYFCGI_LONG_OPT { \
|
|
49
|
+ {"config", required_argument, 0, 'C'},\
|
|
50
|
+ {"pymodule", required_argument, 0, 'e'},\
|
|
51
|
+ {"pyapp", required_argument, 0, 'E'},\
|
|
52
|
+ {"min-worker", required_argument, 0, 'w'},\
|
|
53
|
+ {"max-worker", required_argument, 0, 'W'},\
|
|
54
|
+ {"max-request", required_argument, 0, 'm'},\
|
|
55
|
+ {"log", required_argument, 0, 'L'},\
|
|
56
|
+ {"syslog", no_argument, 0, 'S'},\
|
|
57
|
+ {"pid-file", required_argument, 0, 'P'},\
|
|
58
|
+ {"version", no_argument, 0, 'v'},\
|
|
59
|
+ {"help", no_argument, 0, 'h' },\
|
|
60
|
+ {0, 0, 0, 0}\
|
|
61
|
+}
|
|
62
|
+
|
|
63
|
+#define PYFCGI_OPT_HELP {\
|
|
64
|
+ {"Load options from configuration file", "CONFIG"},\
|
|
65
|
+ {"Search application function in given python module", "MODULE_NAME"},\
|
|
66
|
+ {"Python application entrypoint function name", "FUNC_NAME"},\
|
|
67
|
+ {"Minimum worker in the pool", "INT"},\
|
|
68
|
+ {"Maximum worker in the pool", "INT"},\
|
|
69
|
+ {"Request count after wich the worker is restarted (if 0 never restart)", "INT"},\
|
|
70
|
+ {"Add a logfile using syntax : 'LOGFILE[;FILT][;FMT]'", "LOGGER_SPEC"},\
|
|
71
|
+ {"Use syslog for logging", NULL},\
|
|
72
|
+ {"Create a PID file", "FILENAME"},\
|
|
73
|
+ {"Print PyFCGI and Python version and exit", NULL},\
|
|
74
|
+ {"Display this help and exit", NULL},\
|
|
75
|
+}
|
|
76
|
+
|
|
77
|
+#define PYFCGI_HELP_TEXT "Logger specification format 'LOGFILE[;FILT][;FMT]' with :\n\
|
|
78
|
+\t- LOGFILE the log file name\n\
|
|
79
|
+\t- FILT a number (in decimal or hexadicimal 0xXX) indicating wich\n\
|
|
80
|
+\t facility/level to log\n\
|
|
81
|
+\t- FMT the logline format in a special markup format using fields between { }\n\
|
|
82
|
+\t supported fields are :\n\
|
|
83
|
+\t\t- {datetime} {datetime:SIZE} {datetime:SIZE:FMT} defines a format and a \n\
|
|
84
|
+\t\t constant length for a datetime field. Default : {datetime:25:%F %T%z}\n\
|
|
85
|
+\t\t- {level} the loglevel \n\
|
|
86
|
+\t\t- {facility} the log facility\n\
|
|
87
|
+\t\t- {pid} the process PID\n\
|
|
88
|
+\t\t- {ident} the defined ident (set by process)\n\
|
|
89
|
+\t\t- {msg} the log message (can only appear once)\n\
|
|
90
|
+You can escape { and } by using {{ and }} and all field names can by\n\
|
|
91
|
+abbreviated to one character.\n"
|
|
92
|
+
|
41
|
93
|
/**@brief Friendly name for @ref struct pyfcgi_conf_s
|
42
|
94
|
* @see struct pyfcgi_conf_s */
|
43
|
95
|
typedef struct pyfcgi_conf_s pyfcgi_conf_t;
|
|
@@ -47,6 +99,7 @@ typedef struct pyfcgi_context_s pyfcgi_context_t;
|
47
|
99
|
struct pyfcgi_context_s {
|
48
|
100
|
pid_t pid;
|
49
|
101
|
pid_t ppid;
|
|
102
|
+ char *pidfile;
|
50
|
103
|
};
|
51
|
104
|
|
52
|
105
|
/**@brief Structure containing configuration
|
|
@@ -84,4 +137,16 @@ struct pyfcgi_conf_s
|
84
|
137
|
/**@brief Configuration globals, inherited from parent to childs */
|
85
|
138
|
pyfcgi_conf_t PyFCGI_conf;
|
86
|
139
|
|
|
140
|
+/**@brief Print usage on FD 2 (stdout) */
|
|
141
|
+void usage();
|
|
142
|
+
|
|
143
|
+/**@brief Print pyfcgi & python version on given fd */
|
|
144
|
+void print_version(int);
|
|
145
|
+
|
|
146
|
+/**@brief Parse arguments and store them in conf
|
|
147
|
+ * @return 0 if no error */
|
|
148
|
+int parse_args(int argc, char *argv[]);
|
|
149
|
+
|
|
150
|
+int parse_optlog(const char*);
|
|
151
|
+
|
87
|
152
|
#endif
|