mirror of https://github.com/BOINC/boinc.git
remote job submission: logging improvements
Old: the remote job submission log had a hardwired name, it was being put in possibly the wrong directory, and disabling logging required editing a PHP file. New: logging is enabled by putting <remote_submit_log>filename</remote_submit_log> in your config.xml; the file is put in the <log_dir> directory. Also: you can log the XML request messages (useful mainly for debugging) by putting <remote_submit_request_log>filename</remote_submit_request_log> in config.xml Documented both of these in a new file: https://boinc.berkeley.edu/trac/wiki/RemoteLogs
This commit is contained in:
parent
21a7333381
commit
24b7234204
|
@ -21,22 +21,26 @@
|
|||
|
||||
require_once("../inc/submit_db.inc");
|
||||
|
||||
$log_file = null;
|
||||
$verbose = true;
|
||||
|
||||
// write status and error messages to log
|
||||
//
|
||||
function log_write($x) {
|
||||
global $verbose, $log_file;
|
||||
static $enabled, $log_file;
|
||||
|
||||
if (!$verbose) return;
|
||||
if (!$log_file) {
|
||||
$hostname = gethostname();
|
||||
$log_dir = "../../log_$hostname";
|
||||
if (!file_exists($log_dir)) {
|
||||
mkdir($log_dir);
|
||||
if (!isset($enabled)) {
|
||||
$enabled = false;
|
||||
$filename = parse_config(get_config(), "<remote_submit_log>");
|
||||
if (!$filename) {
|
||||
return;
|
||||
}
|
||||
$log_file = fopen("$log_dir/submit_log.txt", "a");
|
||||
$log_dir = parse_config(get_config(), "<log_dir>");
|
||||
if (!$log_dir) {
|
||||
return;
|
||||
}
|
||||
$log_file = fopen("$log_dir/$filename", "a");
|
||||
if (!$log_file) return;
|
||||
$enabled = true;
|
||||
}
|
||||
if (!$enabled) return;
|
||||
fwrite($log_file, sprintf("%s: %s\n", strftime("%c"), $x));
|
||||
fflush($log_file);
|
||||
}
|
||||
|
|
|
@ -471,6 +471,7 @@ function submit_batch($r) {
|
|||
log_write("batch update to njobs failed");
|
||||
xml_error(-1, "batch->update() failed");
|
||||
}
|
||||
log_write("adding jobs to existing batch $batch_id");
|
||||
} else {
|
||||
$batch_name = (string)($r->batch->batch_name);
|
||||
$batch_name = BoincDb::escape_string($batch_name);
|
||||
|
@ -511,6 +512,7 @@ function submit_batch($r) {
|
|||
log_write("batch update to IN_PROGRESS failed");
|
||||
xml_error(-1, "batch->update() failed");
|
||||
}
|
||||
log_write("updated batch state to IN_PROGRESS");
|
||||
|
||||
echo "<batch_id>$batch_id</batch_id>
|
||||
</submit_batch>
|
||||
|
@ -1022,13 +1024,13 @@ estimate_batch($r);
|
|||
exit;
|
||||
}
|
||||
|
||||
$request_log = parse_config(get_config(), "<remote_submission_log>");
|
||||
// optionally write request message (XML) to log file
|
||||
//
|
||||
$request_log = parse_config(get_config(), "<remote_submit_request_log>");
|
||||
if ($request_log) {
|
||||
$request_log_dir = parse_config(get_config(), "<log_dir>");
|
||||
if ($request_log_dir) {
|
||||
$request_log = $request_log_dir . "/" . $request_log;
|
||||
}
|
||||
if ($file = fopen($request_log, "a+")) {
|
||||
$log_dir = parse_config(get_config(), "<log_dir>");
|
||||
$request_log = $log_dir . "/" . $request_log;
|
||||
if ($file = fopen($request_log, "a")) {
|
||||
fwrite($file, "\n<submit_rpc_handler date=\"" . date(DATE_ATOM) . "\">\n" . $_POST['request'] . "\n</submit_rpc_handler>\n");
|
||||
fclose($file);
|
||||
}
|
||||
|
|
|
@ -191,5 +191,5 @@ def test_get_output_files():
|
|||
print(r)
|
||||
|
||||
#test_query_batch(328)
|
||||
test_submit_batch('batch_41')
|
||||
test_submit_batch('batch_43')
|
||||
#test_create_batch('batch_33')
|
||||
|
|
Loading…
Reference in New Issue