@@ -891,6 +891,40 @@ function fetch_executable_internal(
891891 }
892892 logmsg (LOG_INFO , " 🔥 Pre-heating judgehost completed. " );
893893 continue ;
894+ } elseif ($ type == 'generic_task ' ) {
895+ foreach ($ row as $ judgeTask ) {
896+ if (!(isset ($ judgeTask ['run_script_id ' ]) && isset ($ judgeTask ['run_config ' ]))) {
897+ // TODO: Should we actually exit here, we do for malformed above but the mistake is not on our side.
898+ error ("Received judgehost_check task without run_script_id/run_config. " );
899+ }
900+
901+ $ run_config = dj_json_decode ($ judgeTask ['run_config ' ]);
902+ $ tmpfile = tempnam (TMPDIR , 'generic_task_ ' );
903+ [$ runpath , $ error ] = fetch_executable (
904+ $ workdirpath ,
905+ 'generic_task ' ,
906+ $ judgeTask ['run_script_id ' ],
907+ $ run_config ['hash ' ],
908+ $ judgeTask ['judgetaskid ' ]
909+ );
910+
911+ if (!run_command_safe ([$ runpath , $ tmpfile ])) {
912+ disable ('run_script ' , 'run_script_id ' , $ judgeTask ['run_script_id ' ], "Running ' $ runpath' failed. " );
913+ }
914+
915+ request (
916+ sprintf ('judgehosts/add-generic-task/%s/%s ' , urlencode ($ myhost ), urlencode ((string )$ judgeTask ['judgetaskid ' ])),
917+ 'POST ' ,
918+ ['generic_task ' => rest_encode_file ($ tmpfile , false )],
919+ false
920+ );
921+
922+ unlink ($ tmpfile );
923+ logmsg (LOG_INFO , " ⇡ Uploading task output. " );
924+ }
925+
926+ logmsg (LOG_INFO , " 🔥 Running generic judgehost tasks completed. " );
927+ continue ;
894928 }
895929
896930 // Create workdir for judging.
0 commit comments