File scripts/builder.php changed (mode: 100644) (index 8351cf3..1f3e824) |
... |
... |
function xdispatch_one($key, $data) |
345 |
345 |
break; |
break; |
346 |
346 |
} |
} |
347 |
347 |
|
|
348 |
|
if (strcmp($op, 'stats') == 0) { |
|
|
348 |
|
if (strcmp($op, 'vm_stats') == 0) { |
349 |
349 |
//rg_log_debug($key . ': ' . $jid . ': stats: ' . rg_array2string_short($u)); |
//rg_log_debug($key . ': ' . $jid . ': stats: ' . rg_array2string_short($u)); |
350 |
350 |
rg_build_stats_add($s['db'], $jid, $u['stats']); |
rg_build_stats_add($s['db'], $jid, $u['stats']); |
351 |
351 |
break; |
break; |
|
... |
... |
function rg_process_job($db, &$job) |
746 |
746 |
//rg_log_debug('workers list: ' . rg_array2string($workers_list)); |
//rg_log_debug('workers list: ' . rg_array2string($workers_list)); |
747 |
747 |
|
|
748 |
748 |
// Trying to find a worker in the list of connections |
// Trying to find a worker in the list of connections |
|
749 |
|
$reason = ''; |
749 |
750 |
foreach ($rg_conns as $key => &$i) { |
foreach ($rg_conns as $key => &$i) { |
750 |
751 |
if (strcmp($key, 'master') == 0) |
if (strcmp($key, 'master') == 0) |
751 |
752 |
continue; |
continue; |
|
... |
... |
function rg_process_job($db, &$job) |
753 |
754 |
if (!isset($i['ann'])) { |
if (!isset($i['ann'])) { |
754 |
755 |
//rg_log($key . ': ' . $jid . ': conn has no announce.'); |
//rg_log($key . ': ' . $jid . ': conn has no announce.'); |
755 |
756 |
// TODO: close after some time? |
// TODO: close after some time? |
|
757 |
|
$reason .= 'A'; |
756 |
758 |
continue; |
continue; |
757 |
759 |
} |
} |
758 |
760 |
|
|
759 |
761 |
if (empty($i['ann']['env'])) { |
if (empty($i['ann']['env'])) { |
760 |
762 |
//rg_log($key . ': ' . $jid . ': conn has no environments.'); |
//rg_log($key . ': ' . $jid . ': conn has no environments.'); |
|
763 |
|
$reason .= 'E'; |
761 |
764 |
continue; |
continue; |
762 |
765 |
} |
} |
763 |
766 |
|
|
764 |
767 |
if (($i['worker_uid'] > 0) && ($i['worker_uid'] != $req['uid'])) { |
if (($i['worker_uid'] > 0) && ($i['worker_uid'] != $req['uid'])) { |
765 |
768 |
rg_log($key . ': ' . $jid . ': uids do not match, try next'); |
rg_log($key . ': ' . $jid . ': uids do not match, try next'); |
|
769 |
|
$reason .= 'U'; |
766 |
770 |
continue; |
continue; |
767 |
771 |
} |
} |
768 |
772 |
|
|
|
... |
... |
function rg_process_job($db, &$job) |
771 |
775 |
if (!isset($workers_list[$k])) { |
if (!isset($workers_list[$k])) { |
772 |
776 |
rg_internal_error('Worker ' . $name . ' not found' |
rg_internal_error('Worker ' . $name . ' not found' |
773 |
777 |
. ' in workers_list! Strange!'); |
. ' in workers_list! Strange!'); |
|
778 |
|
$reason .= 'i'; |
774 |
779 |
continue; |
continue; |
775 |
780 |
} |
} |
776 |
781 |
$wi = $workers_list[$k]; |
$wi = $workers_list[$k]; |
777 |
782 |
|
|
778 |
783 |
if (isset($job['avoid'][$k]) && ($job['avoid'][$k] > time())) { |
if (isset($job['avoid'][$k]) && ($job['avoid'][$k] > time())) { |
779 |
784 |
rg_log($key . ': ' . $jid . ': we must avoid worker ' . $name); |
rg_log($key . ': ' . $jid . ': we must avoid worker ' . $name); |
|
785 |
|
$reason .= 'V'; |
780 |
786 |
continue; |
continue; |
781 |
787 |
} |
} |
782 |
788 |
|
|
|
... |
... |
function rg_process_job($db, &$job) |
787 |
793 |
rg_log($key . ': ' . $jid . ': DEBUG: skip worker ' . $name . ' because' |
rg_log($key . ': ' . $jid . ': DEBUG: skip worker ' . $name . ' because' |
788 |
794 |
. ' sent jobs(' . $aj . ')' |
. ' sent jobs(' . $aj . ')' |
789 |
795 |
. ' >= workers(' . $wi['workers'] . ')'); |
. ' >= workers(' . $wi['workers'] . ')'); |
|
796 |
|
$reason .= 'O'; |
790 |
797 |
continue; |
continue; |
791 |
798 |
} |
} |
792 |
799 |
} |
} |
|
... |
... |
function rg_process_job($db, &$job) |
803 |
810 |
$env_found = TRUE; |
$env_found = TRUE; |
804 |
811 |
break; |
break; |
805 |
812 |
} |
} |
806 |
|
if (!$env_found) |
|
|
813 |
|
if (!$env_found) { |
|
814 |
|
$reason .= 'e'; |
807 |
815 |
continue; |
continue; |
|
816 |
|
} |
808 |
817 |
|
|
809 |
818 |
// Send only what is really needed |
// Send only what is really needed |
810 |
819 |
$job2 = $req; |
$job2 = $req; |
|
... |
... |
function rg_process_job($db, &$job) |
835 |
844 |
|
|
836 |
845 |
// TODO: we should signal this and prevent the call if the list of |
// TODO: we should signal this and prevent the call if the list of |
837 |
846 |
// workers does not change. |
// workers does not change. |
838 |
|
rg_log('No workers found! Suspend job for 10s'); |
|
|
847 |
|
rg_log('No workers found [' . $reason . ']! Suspend job for 10s'); |
839 |
848 |
$job['next_try'] = time() + 10; |
$job['next_try'] = time() + 10; |
840 |
849 |
return TRUE; |
return TRUE; |
841 |
850 |
} |
} |
|
... |
... |
$rg_conns['master']['func_new_arg'] = $db; |
906 |
915 |
|
|
907 |
916 |
// What features the builder supports |
// What features the builder supports |
908 |
917 |
$features = array( |
$features = array( |
909 |
|
'allow_stats' => 1, |
|
|
918 |
|
'worker_stats' => 1, |
910 |
919 |
'notify' => 1, |
'notify' => 1, |
911 |
|
'stats' => 1); |
|
|
920 |
|
'vm_stats' => 1); |
|
921 |
|
rg_log_debug('Supported features: ' . rg_array2string($features)); |
912 |
922 |
|
|
913 |
923 |
$workers = 0; |
$workers = 0; |
914 |
924 |
$original_mtime = @filemtime(__FILE__); |
$original_mtime = @filemtime(__FILE__); |