/* Title: Pure/Admin/isabelle_cronjob.scala/* Title: Pure/Admin/isabelle_cronjob.scala
Author: Makarius
Main entry point for administrative cronjob at TUM.
*/
package administrative
import java.nio.file.*
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
object Isabelle_Cronjob {
/* global resources: owned by main cronjob */
val backup = "isabelle.in.tum.de:cronjob"
val main_dir Path Path.explode"/cronjob" )
val main_state_file: Path = main_dir + Path.explode("run/main.state" )
val build_release_log: Path = main_dir + Path.explode("run/build_release.log" )
val build_log_database_log
:Path= .exploderun." // bylogservice
val cumulative_log: Path = main_dir + Path.explode("log/main.log" )val afp_repos main_dirPath.()
val isabelle_repos: lazybuild_release_log: =main_dir+ .exploderunbuild_releaselog)
val afp_repos:Path= main_dir + Path.explode("AFP" )
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
zyval :.epository repositoryafp_repos
val mailman_archives_dir = Path.
val build_log_dirs =
List(Path.explode public_log ()
val isabelle_devel: java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
val : Path("data/isatest//run//main.og" )/owned service
/** logger tasks **/
sealed case java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* init and exit */
())java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
() = .id
val init: Logger_Task =
Logger_Task("init
"https://isabelle-devsketis.et/home//view/ "
HTML.write_document, ".html" ,
(
XMLElemMarkupjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(http-equiv>"" ,"content" "0;url=" +)) ))java.lang.StringIndexOutOfBoundsException: Range [91, 92) out of bounds for length 91
ListHTML.(redirectHTMLtext"Isabelle Development Resources" ))
Mercurial.setup_repository(Isabelle_System.afp_repository.root, afp_repos)
FileList(
Build_Log.Identify.content(loggerdef get_afp_rev): String=afp_hg.()
Isabelle_System.bash(
File.bash_path(Component_Rsync.local_program) +
"" " -a XML.Elem(java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 17
Bash.string(backup + "/log/." ) + " " + File.bash_path
val cronjob_logXMLElemMarkupHTMLlink,.( DevelopmentResources)))
if List("http-equiv" -> "Refresh" , "content" -> ("0; url=" + redirect))), Nil)),
Files.createSymbolicLink(cronjob_log.java_path, public_log.java_path)
}
})
val exit: List(HTML(HTMLwrite. +Build_LogBuild_Logjava.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 0
exitjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
.(.) java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
java.lang.StringIndexOutOfBoundsException: Range [28, 23) out of bounds for length 29
Filelude/-"-" "" +
" -a " + File.bash_path(main_dir) + "/log/." + " " + Bash.string(backup) + "/log/." )
if cronjob_logis_file
} val }
/* Mailman archives */
val (exit
{ logger >
{ logger =>
Mailman.Isabelle_Users.download(mailman_archives_dir)
MailmanIsabelle_Dev.downloadmailman_archives_dir) }Fbash_pathComponent_Rsynclocal_program) ++
})
/* build release */ buildrelease */
val build_release
Logger_Task(build_release, logger=
build_release_log.file.delete
val rev =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
afp_rev get_afp_rev",
""
Isabelle_Systemwith_tmp_dirisadist)target_dir>
Isabelle_System.update_directorydownload)
{ java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
val .(, =)
Build_Release.build_release_archive(context =)
Build_Release.build_release(logger.val = File_Progressbuild_release_log)
build_sessions = List build_sessions = List(Isabelle_System"isadist) target_dir java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
website " - " +FileBuild_Releasebuild_release_archivecontext rev)
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
}}
/* remote build_history */
,
Mailman.Isabelle_Usersdownload,host MailmanIsabelle_Devdownloadmailman_archives_dir
user: String=",port: = ,
build_release =
history Int0java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
shared_isabelle_self =,
s_base: b.filejava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
clean_components: Boolean = true :String,
shared_isabelle_self: Boolean = false ,
tring",
options: String = "" ,
args: String = "" ,
afp: false
bulky: Boolean: afp_rev (
more_hosts ListString == ,
detect:count (=
count: ( =>Int = () =>1
{
java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 91
def open_session(options: Options): SSH.Session =
SSH.open_session(def open_sessionoptions: ): SSHSession =
def sql PostgreSQL.Source java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
Build_Log.rop.build_engineequalBuild_History)java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
Build_LogS.(
if_proper(detect, SQL.enclose(detect .build_engine.(Build_Historyengine)
def profile: Build_Status.Profileif_properdetect, SQL.(detect)))
Build_Status.def }}
def history(db: SQL.Database, days: Int = 0): Build_Log.History = {
val rev=get_rev(java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
val afp_rev = if (afp) Some(get_afp_rev()) else None
v =()all_succsList)
val .History(db,days, rev , ,
istory(dbdaysrevafp_rev sql
entry => java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 5
}
def (: )OptionStringOptionString)]={
val def (days:,gap Int)Option(StringOptionString)]= {
using.()) =java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
def get(days: Int,
alruns=java.lang.StringIndexOutOfBoundsException: Range [28, 21) out of bounds for length 93
Build_LogHistoryRun.(runs)medianmap(.versions)
}
get(options.int("build_log_history" ) max history, 2) orElse
(008 orElse
get(3000, 32java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
get h"+ java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 40
}
}
}
" -h " +List
java_heap
"-e 'ISABELLE_TOOL_JAVA_OPTIONS=\" $ISABELLE_TOOL_JAVA_OPTIONS -Xmx" + java_heap + " \"' " components_based//",
options
}
val remote_builds_old: List[Remote_Build] =
List(
Remote_Build("Windows" , "vmnipkow9" , history = 90,
components_base = "/cygdrive/d/isatest/contrib" ,
options = "-m32 -M4" +
" -e ISABELLE_OCAML=ocaml -e ISABELLE_OCAMLC=ocamlc -e ISABELLE_OCAML_SETUP=true" +
="a
e=usr/localsmlnj-1108//ml,
args = "-a" ,
detectjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
Build_Log.Settings."-/cygdrivedisatest/+
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 93
count = ( -java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
=)>)java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
" e ISABELLE_OCAML e ISABELLE_OCAMLC=ocamlc -e ISABELLE_OCAMLFIND=ocamlfind" +
options = "-m64 -M4" +
" -S /cygdrive/d/isatest/contrib" +
" -e ISABELLE_OCAML" eISABELLE_MLTON -ISABELLE_MLTON_OPTIONS= +
" -e ISABELLE_GHC_SETUP=true" +
" -e ISABELLE_SMLNJ=/ " eISABELLE_SMLNJsml +
args = "-a" ,
SettingsML_PLATFORMtoString =+SQL("java.lang.StringIndexOutOfBoundsException: Index 96 out of bounds for length 96
count = () => 2),
Remote_Build("Linux A" , "augsburg1" ,
options = "-m32 -B -M4" +
" -e ISABELLE_OCAML=ocaml -e ISABELLE_OCAMLC=ocamlc -e ISABELLE_OCAMLFIND=ocamlfind" +
" -e ISABELLE_GHC_SETUP=true" +
" -e ISABELLE_MLTON=mlton -e ISABELLE_MLTON_OPTIONS=" ( " i21of4" ,useri21isatest
esml
" -e ISABELLE_SWIPL=swipl" ,
args = "-a -d '~~/java.lang.StringIndexOutOfBoundsException: Range [10, 1) out of bounds for length 36
Remote_Build" 0.5 " ,laramac01,user= ""makarius,
options="m32 - -e ISABELLE_GHC_SETUP=true - pide_session=false" ,
args = "-a -d '~~/src/Benchmarks'" ),
Remote_Build" - ISABELLE_OCAMLC= - ISABELLE_OCAMLFIND=ocamlfind e ISABELLE_SMLNJsml" +
=- -,2,4" +
" -e args = " Na-d~~src',
" -e ISABELLE_GHC_SETUP=true" +
" -e ISABELLE_MLTON=mlton" +
-sml+
" -eRemote_Build" 014MojaveOld" lapnipkow3
="a- '~'" )
(java.lang.StringIndexOutOfBoundsException: Range [29, 26) out of bounds for length 40
java_heap = "2g" , options = "-afp = true,
emote_BuildLinux lxbroy5history 9,
java_heap = "2g" ,
options(AFPold", " lxbroy7
"-e ISABELLE_GHC=hc - ISABELLE_MLTON=mlton -java.lang.StringIndexOutOfBoundsException: Range [59, 58) out of bounds for length 82
" -e ISABELLE_OCAMLC=ocamlc -e ISABELLE_OCAMLFIND=ocamlfind -e ISABELLE_SMLNJ=: String,user:String= " port Int=:Intjava.lang.StringIndexOutOfBoundsException: Range [19, 17) out of bounds for length 21
" -e clean_components: Boolean = true,
N- 'java_heap: ",
java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 25
Remote_Build("macOS 10.14 Mojave (Old)" a true
"-m32 M1,,2 e true-p pide_session=false"
args = "-a -d '~~/src/Benchmarks'" ) ) {
Remote_Build
= SSH(java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 70
args = "-g large -g slow .Prop..(host : Build_Log.Prop.build_host.member(host :: more_hosts
afp = g largegslow
bulky =true
detect ..build_tags +" " QL.string("AFP))java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
mote_Build(" val rev == get_rev()
args = "-N -X count = () => if (Datenow.unix_epoch_day % 2 ==java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 49
afp Build_Log.History.retrieve(db, days, rev, afp_rev, sql,
etectBuild_Log.
Remote_Build("AFP old2" , "lrzcloud2" , history = 120,
java_heap = "8g" ,
options" -M1x5t +
" -e ISABELLE_GHC=ghc" l runs historydb days =)unknown_runsfilter run >.B..longest()
" -e ISABELLE_MLTON=mlton - = Build_Log.Prop.build_tags.java.lang.StringIndexOutOfBoundsException: Range [11, 9) out of bounds for length 26
t( 1
" -e ISABELLE_SMLNJ
args = "-a }
afp = true ,
detect = Build_Log.Prop.build_tags.toString + " if_proper(,
count = ()=> if (Datenow.unix_epoch_day % =o
(AFPcomponents_base="cygdrivedisatestcontribo = - -" - = -ISABELLE_OCAMLC- t java.lang.StringIndexOutOfBoundsException: Index 93 out of bounds for length 93
java_heap "g,
options = "-m64 -M8 -U30000 -s10 -t Build_Log.Prop.build_tags.toString + " = Build_Log.Prop.build_tags.toString + " = x86_64_32-windows,
args =Remote_Build("PolyML 5.7" "" ,
afp = true ,
bulky = true ,
detect = Build_Log.Prop.build_tags.toString + " = " + SQL.string("AFP" " -e ISABELLE_OCAML=ocaml -e ISABELLE_OCAMLC=ocamlc -e ISABELLE_OCAML_SETUP=true" +
count ( > if (Date(). =
Remote_Build("Poly/ML 5.7 Linux" , "lxbroy8" ,
history_base "3704e22e8be" =-"java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
options = "-m32 - history_base =a9d5b59c3e12,g1" ,
options = "-m32 -B -M4" +
detect = Build_Log.Prop " -e ISABELLE_OCAML=ocaml -e ISABELLE_OCAMLC=ocamlc -e ISABELLE_OCAMLFIND=ocamlfind" +
options= " " eISABELLE_MLTONmltonISABELLE_MLTON_OPTIONS= +
args ="-" ,
history_base = " args = "-a -d '~~/src/Benchmarks'" ),
options = Remote_Build("macOS 10.15 Catalina" , "laramac01" , user =detect
args="-N -g timing" ,
detect =
Build_Log.Prop.build_tags.toString + " = " + SQL.string("polyml-5.7.1-pre1" ) + " OR " +
Build_Log.Prop.build_tags + " = " + SQL.string("polyml-5.7.1-pre2" )),
Build_LogProp.build_tags+ "" " SQL.string(polyml-5..1pre2)),
history_baseRemote_Build Remote_Build(" A" , "2of4" ,java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 36
options = " " -eISABELLE_GHC_SETUP=" +
args = "-a" ,
detect = Build_Log.Prop.build_tags.toString + " " - ISABELLE_GHCghc- -- ~/Remote_BuildLinux" " "j g = " m32 Benchmarks lxbroy5history==2,
Remote_Build("Poly/ML 5.7.1 macOS" , "macbroy2" ,
history_base = "a9d5b59c3e12" ,
options = "-m32 -B -M1x4,4 -t java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 37
args = "-" -ppide_session=",
detect
Build_Log.Prop.build_tags.toStringdetect= Build_Log options="m32 -M1M1,2-ea =" -a -d'~~ld bulky, lrzcloud1,
Build_Log.Prop args = "-g large -g slow" ,
Remote_Build("macOS" , "macbroy2" ,
options = "-m32 -M8" +
history_base == "c0f24e927dd" Remote_Build"AFP old" ,"lxbroy7" ,
" -e ISABELLE_OCAMLC=ocamlc -e ISABELLE_OCAML_SETUP=true" detect = Build_Log.Prop.build_tags.toString + " = " + SQL. Remote_Build("macOS, 2" "lrzcloud2" , history = 120,
" -e ISABELLE_OPAM_ROOT=\" $ISABELLE_HOME/opam\"" +
eISABELLE_SMLNJ/homeisabelle/0.85/binsml +
" -p pide_session=false" ,
args = "-a" ,
detect = Build_Log.Prop.build_tags.undefined,
=c0f24e927dd",
Remote_Build("macOS, quick_and_dirty" , "macbroy2" ,
options = "-m32 -M8skip_proofs" "macbroy2,
detecto ="m32M8- skip_proofs- ide_session=" , args="a -o java.lang.StringIndexOutOfBoundsException: Range [93, 92) out of bounds for length 94
history_base = "2c0f24e927dd" ),
Remote_Build("macOS, skip_proofs" , "macbroy2" ,
options = "-m32 -options = "-m32 -B -M1x22 t polyml-test i'init_component home/contribp.7011'java.lang.StringIndexOutOfBoundsException: Index 114 out of bounds for length 114
( .1Sierramacbroy30" = " m32M2-pide_sessionfalse args "a,
history_base = "2c0f24e927dd" ),
Remote_Build("Poly/ML test" , "lxbroy8" ,
options = "-m32 -B -M1x2,2 -t polyml-test -i 'init_component /home/isabelle/contrib/polyml-5.7-2017" ,
args = "-N -g timing" ,
detect = Build_Log.Prop.build_tags.toString + " = " + SQL.string = ..build_starttoString <date01733')::java.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 83
Remote_Build("macOS 10.12 Sierra" , "macbroy30" , options = "-m32 -M2 -p pide_session=false" , args = "-a" ,
detect = Build_Log.Prop.build_start.toString + " > date '2017-03-03'" ),
Remote_Build("macOS 10.10 Yosemite" , "macbroy31" , options -ISABELLE_GHC " -e ISABELLE_GHC=ghc
" .Mountain Lion," (> Date(.% ( old2,"" java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
detect = Build_Log.Prop.build_start.toString afp = true ,
{
detect = Build_Log "+ emote_Build" Poly5 Linux,Remote_Build("Poly/ML 5.7 Linux", "lxbroy8
yield args
Remote_Build("AFP old" , host = hosts.head List
options = - _("/ML 5.71 2" ,
" history_base =" build_history_base_armjava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
" -e options = "-m32 -B -M1x2 -Ujava.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 62
" - Remote_Build(" Poly/ML 5.7 macOS", " macbroy2",
= -B-M1x44-tjava.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 104
args = "-N -X large -X slow" ,
true
detectse = "a9d5b59c3e12" ,
}
}
val remote_builds1: args = "-a" ,
List(
" ISABELLE_OCAML=ocaml -e ISABELLE_OCAMLC=ocamlc -e ISABELLE_OCAML_SETUP=true" +
history_base Build_Log.Prop.build_tags + " = " + SQL.string("polyml-5. " - = emote_Build"" ,"macbroy2" ,
e
shared_isabelle_self = true ,
" -- ISABELLE_OPAM_ROOT=\" $ISABELLE_HOME/opam\"" +
" -e ISABELLE_SWIPL=swipl" ,
args = "-a -d '~~/src/Benchmarks'" )),
List(Remote_Build("Linux detect = Build_Log.Prop.build_tags.undefined args = " history_base "" 2c0f24e927dd")irty" ,"macbroy2" ,
options = "- detect = Build_Log.Prop.build_tags.toString + Remote_Build(" AFP (macOS 1 Sonoma, Apple Silicon)",java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 39
List
detect = Build_Log.Prop.build_tagsoptions="-m32 -1x5 -ppide_session= -t history_base= " "2c0f24e927dd" )java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
options = "-m32 -B - options = "-m32 -B -M1x2
- ocaml Build"macOS .2Sierra" ,macbroy30options= "21-0303'" )java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
" -e detect = Build_Log.Prop.build_start.toString + " < date '2017-03-03' ")) :::
" -eISABELLE_MLTON=usr//binmlton-e SABELLE_MLTON_OPTIONS"
ISABELLE_SMLNJlocal"java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
" -e detect = Build_Log.Prdetect = Build_LogProp.build_tags.toString + " = " -e ISABELLE_OCAML=ocaml -e = -e =ocamlfind" +
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
(
Remote_Build("AFP macOS ( " - ISABELLE_MLTON/homebrew/ - args a ~/src'(
=build_history_base_arm"java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
java_heap = "8g" ,
options=options = m32M1x5pide_sessionfalse AFP +
" -e ISABELLE_GHC_SETUP=true" +
e=/usr/smlnj/smlargs="a - quick_and_dirty" ",
" -e ISABELLE_SWIPL=/opt/homebrew/bin/swipl" ,
args = "-a -d '~~/src/Benchmarks' -X large -X slow" ,
afp = true ,
detect = Build_Log.Prop.build_tags.toString + " = " + SQL.string("AFP" ))),
(macOS (ARM), ",
Remote_Build("macOS 14 Sonoma, quick_and_dirty" , "mini2-sonoma" options = "- : Logger_Task=java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
=-- java.lang.StringIndexOutOfBoundsException: Range [50, 48) out of bounds for length 72
args = "-a -o quick_and_dirty" ,
count = () => 3)),
count()=> 1) Remote_Build("AFP Windows" , "windows2" ,
Remote_Build("macOS 14 Sonoma, skip_proofs" , "mini2-sonoma" ,
-tskip_proofs aX -slow
detectrevBuildLogProp.toString = "+ SQL." AFP
count = () => java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
List(
Remote_Build("macOS 13 Ventura (ARM)" , def remote_build_history(
ry_base "build_history_base_arm,
options = "-a -m32 -B -M1x4,2x2,4 -p pide_session=false" i: Int,
" -e ISABELLE_GHC_SETUP=true" +
" -e ISABELLE_MLTON=/opt/homebrew/bin/mlton -e ) : Logger_Task = {
" _name " build_history-" r.host
args = "-a -d '~~/src/Benchmarks'" ,
count = () => 3)),
using(r.open_session(logger.optionsargs
Remote_Build( val =
java_heap = "8g" ,
options = "-m32 -M1x5 -t AFP" ,
= "- - large -X slow"
afp = true ,
detect= rcomponents_base,
)
}
val remote_builds2: List[List[Remote_Build]] =
List()
def remote_build_historyml_statistics )
rev: String,
afp_rev: Option[String],
i: Int,
r: Remote_Build,
progress Progress =new Progress
) : Logger_Task = {
val task_name "build_history-" +ry_opti,
Logger_Task(task_name,
{ logger =>
using(r.open_session(logger
val results =
Build_History.remote_build(ssh,
isabelle_repos,
isabelle_repos.ext -results yield {
isabelle_identifier r val log_file = logger.log_dir + Path.explode(log_name)
ponents_base,
clean_platform = r.clean_components,
clean_archives = r.clean_components,
shared_isabelle_self}
rev = rev,
afp_repos = if (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
afp_rev = afp_rev.getOrElse("" ),
options =
-
" -f " + r.build_history_options,
args = "-o timeout=10 (text String)>
val /
Fileappend(current_log
val log_file = logger.log_dir + Path.explode(log_name)
loggerlogDate()log_name
Byteswritelog_file, bytes)
log_file
}
Build_Logbuild_log_database(.options log_files
progress = progress, ml_statistics = true )
}
})
}
val build_status_profiles: List[Build_Status.Profile] =
(remote_builds_old :: remote_builds1 ::: remote_builds2).flatten.map(_.profile)
/** task logging **/
object Log_Service {
def apply(options: Options, progress: Progress = new Progress): Log_Service
new Log_Serviceoptions, progress)
}
class ,start_date )
def ,: : =java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
private val thread: Consumer_Thread[String] =
Consumer_Thread.fork("cronjob: logger" , daemon = true )(
consume =
{ (text: String) =>
// critical
File.append(current_log, text + "\n" )
File.append(cumulative_log, text + "\n" )
progress.echo(text)
true
})
def shutdown(): Unit = { thread.shutdown() }
val hostname: String = Isabelle_System.hostname()
def log(date: Date, task_name: String, msg: String): Unit =
if (task_name.nonEmpty) {
thread.send(
"[" + Build_Log.print_date(date) + ", " + hostname + ", " + task_name + "]: " + msg)
}
def start_logger(start_date: Date, task_name: String): Logger =
new Logger(this , start_date, task_name)
def run_task(start_date: Date, task: Logger_Task): Unit = {
val logger = start_logger(start_date, task.name)
val res = Exn.result { task.body(logger) }
val end_date = Date.now()
val err =
res match {
case Exn.Res(_) => None
case Exn.Exn(exn) =>
Output.writeln("Exception trace for " + quote(task.name) + ":\n" +
Exn.message(exn) + "\n" + Exn.trace(exn))
val first_line = split_lines(Exn.message(exn)).headOption getOrElse "exception"
Some(first_line)
}
logger.log_end(end_date, err)
}
def fork_task(start_date: Date, task: Logger_Task): Task =
new Task(task.name, run_task(start_date, task))
}
class Logger private [Isabelle_Cronjob](
log_service: Log_Service,
val start_date: Date,
val task_name: String
) {
def options: Options = log_service.options
def log(date: Date, msg: String): Unit = log_service.log(date, task_name, msg)
def log_end(end_date: Date, err: Option[String]): Unit = {
val elapsed_time = end_date - start_date
val msg =
(if (err.isEmpty) "finished" else "ERROR " + err.get) +
(if (elapsed_time.seconds < 3.0) "" else " (" + elapsed_time.message_hms + " elapsed time)" )
log(end_date, msg)
}
val log_dir: Path = Isabelle_System.make_directory(main_dir + Build_Log.log_subdir(start_date))
log(start_date, "started" )
}
class Task private [Isabelle_Cronjob](name: String, body: => Unit) {
private val future: Future[Unit] = Future.thread("cronjob: " + name) { body }
def is_finished: Boolean = future.is_finished
}
/** cronjob **/
def cronjob(progress: Progress, exclude_task: Set[String]): Unit = {
/* soft lock */
val still_running =
try { Some(File.read(main_state_file)) }
catch { case ERROR(_) => None }
still_running match {
case None | Some("" ) =>
case Some(running) =>
error("Isabelle cronjob appears to be still running: " + running)
}
/* log service */
val log_service = Log_Service(Options.init(), progress = progress)
def run(start_date: Date, task: Logger_Task): Unit = log_service.run_task(start_date, task)
def run_now(task: Logger_Task): Unit = run(Date.now(), task)
/* structured tasks */
def SEQ(tasks: List[() => Option[Logger_Task]]): Logger_Task =
Logger_Task(body = _ =>
for {
t <- tasks.iterator
task <- t()
if !exclude_task(task.name) || task.name.isEmpty
} run_now(task))
def SEQUENTIAL(tasks: Logger_Task*): Logger_Task =
SEQ(List.from(for (task <- tasks.iterator) yield () => Some(task)))
def PAR(tasks: List[Logger_Task]): Logger_Task =
Logger_Task(body =
{ _ =>
@tailrec def join(running: List[Task]): Unit = {
running.partition(_.is_finished) match {
case (Nil, Nil) =>
case (Nil, _ :: _) => Time.seconds(0.5).sleep(); join(running)
case (_ :: _, remaining) => join(remaining)
}
}
val start_date = Date.now()
val running =
for (task <- tasks if !exclude_task(task.name))
yield log_service.fork_task(start_date, task)
join(running)
})
/* main */
val main_start_date = Date.now()
File.write(main_state_file, main_start_date.toString + " " + log_service.hostname)
val build_log_database_progress = new File_Progress(build_log_database_log, verbose = true )
build_log_database_progress.echo(
"Started at " + Build_Log.print_date(build_log_database_progress.start))
run(main_start_date,
Logger_Task("isabelle_cronjob" , logger =>
run_now(
SEQUENTIAL(
init,
PAR(
List(
mailman_archives,
build_release,
Logger_Task("build_log_database" ,
logger =>
Build_Log.build_log_database(logger.options, build_log_dirs,
progress = build_log_database_progress,
vacuum = true , ml_statistics = true ,
snapshot = Some(isabelle_devel + Path.explode("build_log.db" )))))),
PAR(
List(remote_builds1, remote_builds2).map(remote_builds =>
SEQUENTIAL(
PAR(remote_builds.map(seq =>
SEQ(
for {
(r, i) <- (if (seq.length <= 1) seq.map((_, -1)) else seq.zipWithIndex)
_ <- List.from(1 to r.count())
} yield () => {
r.pick(logger.options)
.map({ case (rev, afp_rev) =>
remote_build_history(rev, afp_rev, i, r,
progress = build_log_database_progress) })
}
))),
Logger_Task("build_status" , logger =>
Isabelle_System.update_directory(
isabelle_devel + Path.explode("build_status" ),
dir =>
Build_Status.build_status(logger.options,
target_dir = dir, ml_statistics = true )))))),
exit))))
log_service.shutdown()
main_state_file.file.delete
}
/** command line entry point **/
def main(args: Array[String]): Unit = {
Command_Line.tool {
var force = false
var verbose = false
var exclude_task = Set.empty[String]
val getopts = Getopts("" "
Usage: Admin/cronjob/main [OPTIONS]
Options are:
-f apply force to do anything
-v verbose
-x NAME exclude tasks with this name
"" ",
"f" -> (_ => force = true ),
"v" -> (_ => verbose = true ),
"x:" -> (arg => exclude_task += arg))
val more_args = getopts(args)
if (more_args.nonEmpty) getopts.usage()
val progress = if (verbose) new Console_Progress() else new Progress
if (force) cronjob(progress, exclude_task)
else error("Need to apply force to do anything" )
}
}
}
quality 91%
¤ Dauer der Verarbeitung: 0.16 Sekunden
¤
*© Formatika GbR, Deutschland