Tests about a simple python3 fastcgi runner using libfcgi and the Python-C API.
python
c
wsgi
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #include "conf.h"
  2. void usage()
  3. {
  4. static const struct option opts[] = PYFCGI_LONG_OPT;
  5. static const char *help[][2] = PYFCGI_OPT_HELP;
  6. size_t i;
  7. dprintf(2, "Usage : %s -e PYMODULE -E PYFUN [OPTIONS]\n", PYFCGI_NAME);
  8. dprintf(2, "\nOptions list :\n");
  9. i=0;
  10. while(opts[i].name)
  11. {
  12. dprintf(2, "\t-%c, --%s", opts[i].val, opts[i].name);
  13. switch(opts[i].has_arg)
  14. {
  15. case required_argument:
  16. dprintf(2, "=%s\n",
  17. help[i][1]?help[i][1]:"ARG");
  18. break;
  19. case optional_argument:
  20. dprintf(2, "[=%s]\n",
  21. help[i][1]?help[i][1]:"ARG");
  22. break;
  23. default: //no_argument
  24. dprintf(2, "\n");
  25. }
  26. printf("\t\t%s\n\n", help[i][0]);
  27. i++;
  28. }
  29. dprintf(2, "%s", PYFCGI_HELP_TEXT);
  30. }
  31. void print_version(int fd)
  32. {
  33. dprintf(fd, "%s\n", PACKAGE_STRING);
  34. }
  35. int parse_args(int argc, char *argv[])
  36. {
  37. static const struct option long_options[] = PYFCGI_LONG_OPT;
  38. int c, opt_i;
  39. while(1)
  40. {
  41. c = getopt_long(argc, argv, PYFCGI_SHORT_OPT, long_options,
  42. &opt_i);
  43. if(c == -1) { break; }
  44. switch(c)
  45. {
  46. case 'v':
  47. print_version(1);
  48. exit(0);
  49. case 'C':
  50. dprintf(2, "Config parser not yet implemented :'(\n");
  51. exit(1);
  52. case 'e':
  53. PyFCGI_conf.py_entrymod = strdup(optarg);
  54. break;
  55. case 'E':
  56. PyFCGI_conf.py_entryfun = strdup(optarg);
  57. break;
  58. case 'w':
  59. PyFCGI_conf.min_wrk = atoi(optarg);
  60. break;
  61. case 'W':
  62. PyFCGI_conf.max_wrk = atoi(optarg);
  63. break;
  64. case 'm':
  65. PyFCGI_conf.max_reqs = atoi(optarg);
  66. if(PyFCGI_conf.max_reqs < 0)
  67. {
  68. PyFCGI_conf.max_reqs = 0;
  69. }
  70. break;
  71. case 'L':
  72. if(parse_optlog(optarg))
  73. {
  74. exit(1);
  75. }
  76. break;
  77. case 'S':
  78. PyFCGI_conf.logs.flags |= PYFCGI_LOG_FSYSLOG;
  79. break;
  80. case 'P':
  81. PyFCGI_conf.context.pidfile = strdup(optarg);
  82. break;
  83. case 'h':
  84. usage();
  85. exit(0);
  86. default:
  87. usage();
  88. exit(1);
  89. }
  90. }
  91. if(optind < argc)
  92. {
  93. for(opt_i=optind; opt_i<argc; opt_i++)
  94. {
  95. dprintf(2, "Unkown argument '%s'\n", argv[opt_i]);
  96. }
  97. usage();
  98. exit(1);
  99. }
  100. return 0;
  101. }
  102. int parse_optlog(const char* logspec)
  103. {
  104. return 0;
  105. }