From f128cdce1b2ee7ecdb530082386f3d9f24f8228a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 18 Nov 2023 14:17:30 -0800 Subject: [PATCH 1/8] Minor changes to facilitate the server setup demo: - Instructions for Apache: copy config file to sites_enabled/ rather than appending it to the main config file - default job replication is 1 - fix format of items on op pages --- apps/uppercase_in | 9 +++++++++ apps/uppercase_out | 15 +++++++++++++++ html/inc/util_ops.inc | 2 +- tools/backend_lib.h | 4 ++-- tools/make_project | 19 ++++++------------- 5 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 apps/uppercase_in create mode 100644 apps/uppercase_out diff --git a/apps/uppercase_in b/apps/uppercase_in new file mode 100644 index 00000000000..61615294474 --- /dev/null +++ b/apps/uppercase_in @@ -0,0 +1,9 @@ + + + + + + in + + + diff --git a/apps/uppercase_out b/apps/uppercase_out new file mode 100644 index 00000000000..96f8f51abc3 --- /dev/null +++ b/apps/uppercase_out @@ -0,0 +1,15 @@ + + + + + + 5000000 + + + + + + out + + + diff --git a/html/inc/util_ops.inc b/html/inc/util_ops.inc index 5972e7744ee..9b2dc00affa 100644 --- a/html/inc/util_ops.inc +++ b/html/inc/util_ops.inc @@ -83,7 +83,7 @@ function print_text_field($text,$name,$value) { } function row($x, $y) { - echo "$x\n$y\n\n"; + echo "$x    \n$y\n\n"; } function c_row2($color, $x, $y) { diff --git a/tools/backend_lib.h b/tools/backend_lib.h index 8e55325631d..7add38dfb3d 100644 --- a/tools/backend_lib.h +++ b/tools/backend_lib.h @@ -26,8 +26,8 @@ // default job parameters // -#define DEFAULT_MIN_QUORUM 2 -#define DEFAULT_TARGET_NRESULTS 2 +#define DEFAULT_MIN_QUORUM 1 +#define DEFAULT_TARGET_NRESULTS 1 #define DEFAULT_MAX_ERROR_RESULTS 3 #define DEFAULT_MAX_TOTAL_RESULTS 10 #define DEFAULT_MAX_SUCCESS_RESULTS 6 diff --git a/tools/make_project b/tools/make_project index 5545427c683..c7d579d0b8b 100755 --- a/tools/make_project +++ b/tools/make_project @@ -468,19 +468,12 @@ html_ops_url = options.html_ops_url content = '''Steps to complete installation: -- Change Apache configuration (as root): - - If you are using Apache 2.4, edit the %(httpd_conf_template_filename)s - (see file for specific instructions). - - cat %(httpd_conf_template_filename)s >> /etc/apache/httpd.conf - - (path to httpd.conf varies; try /etc/httpd/ or /etc/apache2) - - Then restart the web server: - - /usr/sbin/apache2ctl restart - (or /usr/sbin/apachectl restart) +- Update Apache configuration (as root): + (make sure you have apache2 2.4 or later) + install config file: + cp %(httpd_conf_template_filename)s /etc/apache2/sites-enabled + restart apache: + apache2ctl restart - Add to crontab (as %(USER)s) From 43e76adb20e94b1d48733a9550ae348f42112efc Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 18 Nov 2023 15:03:19 -0800 Subject: [PATCH 2/8] server demo: add example templates and version.xml to apps/ --- apps/version.xml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 apps/version.xml diff --git a/apps/version.xml b/apps/version.xml new file mode 100644 index 00000000000..b5c31fd6ae2 --- /dev/null +++ b/apps/version.xml @@ -0,0 +1,6 @@ + + + upper_case + + + From bf36cfbb83027e615c198a62969f2be20280f0d9 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 19 Nov 2023 13:31:52 -0800 Subject: [PATCH 3/8] - rename apps/upper_case to uppercase - update tools/demo_query: show errors as text if in progress, show status and exit - tools/demo_submit: exit after submit --- apps/Makefile.am | 10 +++--- apps/{upper_case.cpp => uppercase.cpp} | 0 html/inc/db_ops.inc | 4 +-- html/inc/result.inc | 12 ++++--- tools/demo_query | 43 +++++++++++++++----------- tools/demo_submit | 5 ++- 6 files changed, 41 insertions(+), 33 deletions(-) rename apps/{upper_case.cpp => uppercase.cpp} (100%) diff --git a/apps/Makefile.am b/apps/Makefile.am index c561f147633..640ecb812a5 100644 --- a/apps/Makefile.am +++ b/apps/Makefile.am @@ -4,12 +4,12 @@ include $(top_srcdir)/Makefile.incl exampledir = $(libexecdir)/boinc-apps-examples -example_PROGRAMS = upper_case concat 1sec +example_PROGRAMS = uppercase concat 1sec -upper_case_SOURCES = upper_case.cpp -upper_case_CXXFLAGS = $(PTHREAD_CFLAGS) -upper_case_LDFLAGS = -static-libtool-libs $(PTHREAD_CFLAGS) -upper_case_LDADD = $(APPLIBS) +uppercase_SOURCES = uppercase.cpp +uppercase_CXXFLAGS = $(PTHREAD_CFLAGS) +uppercase_LDFLAGS = -static-libtool-libs $(PTHREAD_CFLAGS) +uppercase_LDADD = $(APPLIBS) concat_SOURCES = concat.cpp concat_CXXFLAGS = $(PTHREAD_CFLAGS) diff --git a/apps/upper_case.cpp b/apps/uppercase.cpp similarity index 100% rename from apps/upper_case.cpp rename to apps/uppercase.cpp diff --git a/html/inc/db_ops.inc b/html/inc/db_ops.inc index a259be7b063..71349f3bc15 100644 --- a/html/inc/db_ops.inc +++ b/html/inc/db_ops.inc @@ -976,7 +976,7 @@ function admin_show_workunit($wu) { row("Canonical credit", $wu->canonical_credit); //row("Timeout check time", time_str($wu->timeout_check_time)); row("Delay bound", "$wu->delay_bound" . " = " . time_diff($wu->delay_bound) ); - row("Error mask", wu_error_mask_str($wu->error_mask)); + row("Error mask", wu_error_mask_str($wu->error_mask, true)); row("File delete state", file_delete_state_str($wu->file_delete_state)." [".$wu->file_delete_state."]"); row("Assimilation state", assimilate_state_str($wu->assimilate_state)." [".$wu->assimilate_state."]"); // row("","id&detail=low>Show associated results"); @@ -1028,7 +1028,7 @@ function admin_show_workunit_short($wu) { $wu->id, $wu->id ); - $e = wu_error_mask_str($wu->error_mask); + $e = wu_error_mask_str($wu->error_mask, true); $f = file_delete_state_str($wu->file_delete_state); $a = assimilate_state_str($wu->assimilate_state); echo " diff --git a/html/inc/result.inc b/html/inc/result.inc index aa488a94a34..2bf13f5dee6 100644 --- a/html/inc/result.inc +++ b/html/inc/result.inc @@ -310,7 +310,11 @@ function file_delete_state_str($s) { } return "Unknown"; } -function wu_error_mask_str($s) { + +// convert WU error bitmask to str. +// If $color, add HTML red color +// +function wu_error_mask_str($s, $color=false) { $x = ""; if ($s & WU_ERROR_COULDNT_SEND_RESULT) { $x = $x." ".tra("Couldn't send result"); @@ -339,10 +343,8 @@ function wu_error_mask_str($s) { if ($s) { $x = $x." ".tra("Unrecognized Error: %1", $s); } - if (strlen($x)) { - $x="".$x.""; - } else { - $x=""; + if ($color) { + return sprintf('%s', $x); } return $x; } diff --git a/tools/demo_query b/tools/demo_query index 12d30563743..5a2c39819f0 100755 --- a/tools/demo_query +++ b/tools/demo_query @@ -3,30 +3,35 @@ error_mask) { - echo "job error: $wu->error_mask\n"; - break; + echo sprintf("Job error: %s\n", + wu_error_mask_str($wu->error_mask) + ); + return; } - if ($wu->assimilate_state == 2) { + switch ($wu->assimilate_state) { + case ASSIMILATE_INIT: + echo "Job is in progress.\n"; + break; + case ASSIMILATE_READY: + echo "Job waiting for assimilation.\n"; + break; + case ASSIMILATE_DONE: $result = BoincResult::lookup_id($wu->canonical_resultid); $host = BoincHost::lookup_id($result->hostid); $user = BoincUser::lookup_id($result->userid); @@ -38,12 +43,14 @@ while (1) { if (!is_file($outfile)) { die("output file is missing: $outfile\n"); } - echo "output file:\n"; + echo "Output file (sample_result/$wu_name):\n"; readfile($outfile); break; } - sleep(5); - $wu = BoincWorkunit::lookup("name='$wu_name'"); } +if ($argc != 2) { + die("usage: demo_query jobname\n"); +} +main($argv[1]); ?> diff --git a/tools/demo_submit b/tools/demo_submit index d82869bbaa4..d6fcd9c9bef 100755 --- a/tools/demo_submit +++ b/tools/demo_submit @@ -6,8 +6,8 @@ // // usage: demo_submit appname infile // -// Submit a job, show its name, wait for it to complete -// (or you can use demo_query to query status later) +// Submit a job and show its name. +// Use demo_query to query its status and get output file. // // This is for demo use, not production. It assumes: // - template files are appname_in.xml and appname_out.xml @@ -50,5 +50,4 @@ system("bin/create_work --appname $appname --wu_name $wu_name --wu_template $in_ echo "Job name: $wu_name\n"; -system("bin/demo_query $wu_name"); ?> From 5943a39a2da7a02e3c9b3ca5176015c42816fb57 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 19 Nov 2023 14:47:24 -0800 Subject: [PATCH 4/8] - fix filename in apps/version.xml - admin web: don't show plan class twice in app version page - python scripts: if get XML parse error, show name of file it's in - make_project: fix apache instructions --- apps/version.xml | 2 +- html/inc/db_ops.inc | 1 - py/Boinc/boincxml.py | 4 ++-- tools/make_project | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/version.xml b/apps/version.xml index b5c31fd6ae2..588d52298ce 100644 --- a/apps/version.xml +++ b/apps/version.xml @@ -1,6 +1,6 @@ - upper_case + uppercase diff --git a/html/inc/db_ops.inc b/html/inc/db_ops.inc index 71349f3bc15..eaa1002b0a7 100644 --- a/html/inc/db_ops.inc +++ b/html/inc/db_ops.inc @@ -773,7 +773,6 @@ function admin_show_app_version($app_version) { row("min_core_version", $app_version->min_core_version); row("max_core_version", $app_version->max_core_version); row("deprecated", $app_version->deprecated); - row("plan_class", $app_version->plan_class); end_table(); } diff --git a/py/Boinc/boincxml.py b/py/Boinc/boincxml.py index e23ee72dfe0..fe5d9691b5a 100644 --- a/py/Boinc/boincxml.py +++ b/py/Boinc/boincxml.py @@ -127,9 +127,9 @@ def read(self, failopen_ok=False): self.xml = xml.dom.minidom.parse(self.filename) strip_white_space(self.xml) except: + print("Warning: couldn't parse XML file:", self.filename, file=sys.stderr) if not failopen_ok: - raise Exception("Couldn't parse XML config\n") - print("Warning: couldn't parse XML file", file=sys.stderr) + raise Exception("Couldn't parse XML file\n") self._init_empty_xml() try: self._get_elements() diff --git a/tools/make_project b/tools/make_project index c7d579d0b8b..b75f20701a5 100755 --- a/tools/make_project +++ b/tools/make_project @@ -471,7 +471,7 @@ content = '''Steps to complete installation: - Update Apache configuration (as root): (make sure you have apache2 2.4 or later) install config file: - cp %(httpd_conf_template_filename)s /etc/apache2/sites-enabled + cp %(project_shortname+'.httpd.conf')s /etc/apache2/sites-enabled restart apache: apache2ctl restart From 1ccebc0779a33d25ffbd53991272970d87b4f779 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 19 Nov 2023 14:59:20 -0800 Subject: [PATCH 5/8] make_project fix: let's use 'path' for full path --- tools/make_project | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/make_project b/tools/make_project index b75f20701a5..9ea396f328b 100755 --- a/tools/make_project +++ b/tools/make_project @@ -343,10 +343,11 @@ if options.test_app: pf.write() -httpd_conf_template_filename = os.path.join( +httpd_conf_template_filename = project_shortname+'.httpd.conf' +httpd_conf_template_path = os.path.join( options.project_root, - project_shortname+'.httpd.conf' - ) + http_conf_template_filename +) content =''' ## Settings for BOINC project %(project_longname)s @@ -404,7 +405,7 @@ content =''' ''' % locals() -f = open(httpd_conf_template_filename,'w') +f = open(httpd_conf_template_path,'w') f.write(content) f.close() @@ -471,7 +472,7 @@ content = '''Steps to complete installation: - Update Apache configuration (as root): (make sure you have apache2 2.4 or later) install config file: - cp %(project_shortname+'.httpd.conf')s /etc/apache2/sites-enabled + cp %(httpd_conf_template_filename)s /etc/apache2/sites-enabled restart apache: apache2ctl restart From 658e19b2679ee7fd59339fa0d68dea359b074f17 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 19 Nov 2023 15:02:06 -0800 Subject: [PATCH 6/8] make_project: fix typo --- tools/make_project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/make_project b/tools/make_project index 9ea396f328b..795136da2dc 100755 --- a/tools/make_project +++ b/tools/make_project @@ -346,7 +346,7 @@ if options.test_app: httpd_conf_template_filename = project_shortname+'.httpd.conf' httpd_conf_template_path = os.path.join( options.project_root, - http_conf_template_filename + httpd_conf_template_filename ) content =''' From 41be6363499d5100a57b2ad5cd7247a9f1b8a419 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 19 Nov 2023 16:43:30 -0800 Subject: [PATCH 7/8] demo_submit: bug fix --- tools/demo_submit | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/tools/demo_submit b/tools/demo_submit index d6fcd9c9bef..f5a893dac7a 100755 --- a/tools/demo_submit +++ b/tools/demo_submit @@ -10,7 +10,8 @@ // Use demo_query to query its status and get output file. // // This is for demo use, not production. It assumes: -// - template files are appname_in.xml and appname_out.xml +// - template files are appname_in and appname_out +// - the app uses sample_trivial_validator // - the app uses sample_assimilator // (which puts output files in sample_results/) // - app has 1 input file and 1 output file @@ -34,19 +35,10 @@ if (!is_file($fname)) { die("no such file: $fname\n"); } -$in_template = "templates/".$appname."_in.xml"; -if (!is_file($in_template)) { - die("no input template: $in_template\n"); -} -$out_template = "templates/".$appname."_out.xml"; -if (!is_file($out_template)) { - die("no output template: $out_template\n"); -} - system("cp $fname `bin/dir_hier_path $fname`"); $wu_name = $appname."_".$fname."_".(string)time(); -system("bin/create_work --appname $appname --wu_name $wu_name --wu_template $in_template --result_template $out_template $fname"); +system("bin/create_work --appname $appname --wu_name $wu_name $fname"); echo "Job name: $wu_name\n"; From 73d23fdcd7acce1af1ba526b7f8b33a91c5f9687 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 20 Nov 2023 12:56:18 -0800 Subject: [PATCH 8/8] fix bug in boinc::fscanf() This was reading a line with fgets(), then removing the last character from it (usually but not necessarily a newline). This is incorrect. It broke the logic for checking .md5 files (which look for the newline) --- lib/boinc_stdio.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/boinc_stdio.h b/lib/boinc_stdio.h index 2a7f6c5dbef..00875bfd893 100644 --- a/lib/boinc_stdio.h +++ b/lib/boinc_stdio.h @@ -183,7 +183,6 @@ namespace boinc { inline int fscanf(FILE *fp, const char *format, ...) { char buf[BUFSIZ]; boinc::fgets(buf,BUFSIZ,fp); - buf[strlen(buf)-1]=0; va_list va; va_start(va, format); int i=::vsscanf(buf,format,va);