Overview

Namespaces

  • cli_db
    • propel
      • map
      • om
  • cli_import
  • LoggedPDO
  • None
  • PHP
  • webservices
    • cart
    • combisearch
    • details
      • annotations
        • feature
    • graphs
      • barplot
      • genome
    • listing
    • queue

Classes

  • Console_CommandLine_Action_ExtendedHelp
  • LightOpenID
  • Log_firebugJSON
  • WebService

Interfaces

  • CLI_Command

Functions

  • acquire_database
  • cli_error_handler
  • connect_queue_db
  • create_job
  • display_feature
  • display_feature_by_id
  • display_isoform_by_id
  • display_unigene_by_id
  • download
  • execute_command
  • execute_job
  • execute_query_dir
  • get_db_connection
  • get_job_results
  • get_program_databases
  • myErrorHandler
  • pdo_connect
  • report_results_cleanup
  • requestVal
  • smarty_function_call_webservice
  • smarty_function_dbxreflink
  • smarty_function_interprolink
  • smarty_function_publink
  • smarty_modifier_clean_id
  • split_fasta
  • unzip
  • Overview
  • Namespace
  • Function
  • Tree
 1: #!/usr/bin/php
 2: <?php
 3: chdir(__DIR__);
 4: 
 5: require_once('functions.php');
 6: 
 7: if ($argc !== 2)
 8:     die("This command has to be called with exactly one(!) parameter: the path to the config file.\n");
 9: 
10: $configfile = $argv[1];
11: 
12: set_error_handler("myErrorHandler");
13: 
14: if (!stream_resolve_include_path($configfile))
15:     die(sprintf("Missing config file: %s\n", $configfile));
16: require_once $configfile;
17: 
18: 
19: $supported_programs = unserialize(SUPPORTED_PROGRAMS);
20: $supported_programs_qmarks = implode(',', array_fill(0, count($supported_programs), '?'));
21: 
22: while (true) {
23:     $pdo = pdo_connect();
24:     $stm_get_job = $pdo->prepare('SELECT * FROM request_job(?, ?, ARRAY[' . $supported_programs_qmarks . '])');
25:     $stm_get_job->execute(array_merge(array(MAX_FORKS, HOSTNAME), array_keys($supported_programs)));
26:     if ($stm_get_job->rowCount() > 0) {
27:         $job = $stm_get_job->fetch(PDO::FETCH_ASSOC);
28:         /* we don't want fork to mess with our pdo object. this will cause trouble. */
29:         unset($pdo, $stm_get_job);
30: 
31:         //works with unix systems
32:         if (function_exists('pcntl_fork')) {
33:             $pid = pcntl_fork();
34:             if ($pid == -1) {
35:                 die('forking failed! quitting.');
36:             } else if ($pid) {
37:                 //try if we can get another job
38:                 continue;
39:             } else {
40:                 include "worker-thread.php";
41:             }
42:         } 
43:         //we are in windows, try it a different way
44:         else {
45:             $tmpfile = tempnam(sys_get_temp_dir(), "worker");
46:             file_put_contents($tmpfile, serialize(array('job'=>$job, 'configfile'=>$configfile)));
47:             exec(sprintf('psexec -d php.exe worker-thread.php "%s"', $tmpfile));
48:         }
49:     } else {
50:         usleep(5 * 1000 * 1000);
51:     }
52: }
53: 
54: 
55: //handles only E_USER_NOTICE, rest is still handled my php
56: function myErrorHandler($errno, $errstr, $errfile, $errline)
57: {
58:     if (!(error_reporting() & $errno)) {
59:         // This error code is not included in error_reporting
60:         return;
61:     }
62:     if ($errno == E_USER_NOTICE){
63:         printf("Notice: %s in %s on line %d\n", $errstr, $errfile, $errline);
64:         //php should no more handle this
65:         return true;
66:     }
67:     //let php handle this
68:     return false;
69: }
70: ?>
tbro API documentation generated by ApiGen 2.8.0