fcgi_run.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. define('BASE_ROOT_PATH',str_replace('\\','/',dirname(__FILE__)));
  3. require_once (BASE_ROOT_PATH . '/fooder.php');
  4. function run_fcgi()
  5. {
  6. if(OS_TYPE == 'MAC') {
  7. $log_file = new SplFileObject('/Users/stanley-king/logs/shopnc.log','a');
  8. } elseif (OS_TYPE == 'LINUX') {
  9. $log_file = new SplFileObject(BASE_ROOT_PATH . '/php_example.txt','a+');
  10. } else {
  11. $log_file = new SplFileObject('./php_example.txt','a+');
  12. }
  13. $log_file->fwrite("before fcgi_init\r\n");
  14. fcgi_init('/Users/stanley-king/logs');
  15. $log_file->fwrite("end fcgi_init\r\n");
  16. $log_file->fwrite("before fcgi_accept\r\n");
  17. while(($ret = fcgi_accept()) >= 0)
  18. {
  19. $log_file->fwrite("end fcgi_accept\r\n");
  20. define('StartTime',microtime(true));
  21. define('TIMESTAMP',time());
  22. printf("Content-Type: text/html; charset=UTF-8\r\n\r\n");
  23. try
  24. {
  25. init_request();
  26. $file = request_helper::script_file();
  27. if(is_file($file)) {
  28. //include $file;
  29. }
  30. echo 'xxx';
  31. } catch (Exception $ex) {
  32. echo $ex->getTraceAsString();
  33. }
  34. fcgi_finish();
  35. }
  36. fcgi_fini();
  37. }
  38. run_fcgi();
  39. ?>