45 $IPaddr =
'127.0.0.1';
50 if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) ===
false) {
51 $ErrorMsg =
"socket_create() failed: reason: " . socket_strerror(socket_last_error()) .
"<br>\n";
56 if ($result ===
false) {
57 $ErrorMsg =
"Connection to the scheduler failed. Is the scheduler running?<br>";
58 $ErrorMsg .=
"socket_connect() failed.\nReason: ($result) " . socket_strerror(socket_last_error($sock)) .
"<br>\n";
75 return socket_read($SchedObj, $MaxSize, PHP_NORMAL_READ);
91 return socket_write($SchedObj, $msg, strlen($msg));
103 socket_close($SchedObj);
135 $address = $SysConf[
'FOSSOLOGY'][
'address'];
136 $port = $SysConf[
'FOSSOLOGY'][
'port'];
145 if (substr($buf, 0, 3) ==
"end") {
148 if (substr($buf, 0, 8) ==
"received") {
155 if (substr($input, 0, 6) !=
"status" && substr($input, 0, 6) !=
"agents") {
159 $output .=
"$buf<br>";
163 $error_msg = socket_strerror(socket_last_error($sock));
168 return empty($error_msg);
194 if (
false === $command_status) {
197 $pattern =
'/job:(\d+) /';
198 preg_match_all($pattern, $status_info, $matches);
200 $job_array = $matches[1];
201 sort($job_array, SORT_NUMERIC);
GetRunnableJobList()
Get runnable job list, the process is below:
fo_scheduler_write($SchedObj, $msg)
Write to the scheduler socket.
fo_communicate_with_scheduler($input, &$output, &$error_msg)
Communicate with scheduler, send commands to the scheduler, then get the output.
fo_scheduler_close($SchedObj)
Close the scheduler connection (socket).
int socket_connect(char *host, char *port)
Create a socket connection.
fo_scheduler_read($SchedObj, $MaxSize=2048)
Read the scheduler socket.
fo_scheduler_connect($IPaddr='', $Port='', &$ErrorMsg="")
Connect to the scheduler.
char * trim(char *ptext)
Trimming whitespace.