src/Pure/Admin/isabelle_cronjob.scala
author wenzelm
Tue Oct 11 20:20:32 2016 +0200 (2016-10-11)
changeset 64148 bbf43b7c4d0d
child 64153 769791954872
permissions -rw-r--r--
basic setup for Isabelle cronjob;
wenzelm@64148
     1
/*  Title:      Pure/Admin/isabelle_cronjob.scala
wenzelm@64148
     2
    Author:     Makarius
wenzelm@64148
     3
wenzelm@64148
     4
Main entry point for administrative cronjob at TUM.
wenzelm@64148
     5
*/
wenzelm@64148
     6
wenzelm@64148
     7
package isabelle
wenzelm@64148
     8
wenzelm@64148
     9
wenzelm@64148
    10
object Isabelle_Cronjob
wenzelm@64148
    11
{
wenzelm@64148
    12
  def main(args: Array[String])
wenzelm@64148
    13
  {
wenzelm@64148
    14
    Command_Line.tool0 {
wenzelm@64148
    15
      var force = false
wenzelm@64148
    16
      var verbose = false
wenzelm@64148
    17
wenzelm@64148
    18
      val getopts = Getopts("""
wenzelm@64148
    19
Usage: Admin/cronjob/main [OPTIONS]
wenzelm@64148
    20
wenzelm@64148
    21
  Options are:
wenzelm@64148
    22
    -f           apply force to do anything
wenzelm@64148
    23
    -v           verbose
wenzelm@64148
    24
""",
wenzelm@64148
    25
        "f" -> (_ => force = true),
wenzelm@64148
    26
        "v" -> (_ => verbose = true))
wenzelm@64148
    27
wenzelm@64148
    28
      val more_args = getopts(args)
wenzelm@64148
    29
      if (more_args.nonEmpty) getopts.usage()
wenzelm@64148
    30
wenzelm@64148
    31
      if (verbose) Output.writeln("This is the Isabelle cronjob")
wenzelm@64148
    32
wenzelm@64148
    33
      val rc =
wenzelm@64148
    34
        if (force) {
wenzelm@64148
    35
          Thread.sleep(Time.seconds(30).ms)
wenzelm@64148
    36
          0
wenzelm@64148
    37
        }
wenzelm@64148
    38
        else { Output.warning("Need to apply force to do anything"); 1 }
wenzelm@64148
    39
wenzelm@64148
    40
      if (rc != 0) sys.exit(rc)
wenzelm@64148
    41
    }
wenzelm@64148
    42
  }
wenzelm@64148
    43
}