open Printf;;
let broker_url = "localhost:49081/act";;
+let dump_environment_on_exit = false;;
let init_tutor = Hbugs_id_generator.new_tutor_id;;
val hint: hint
val hint_type: hint_type
val description: string
+ val environment_file: string
end
module BuildTutor (Dsc: HbugsTutorDescription) : HbugsTutor =
(Exception ("parse_error", reason)))
outchan
+ let restore_environment () =
+ let ic = open_in Dsc.environment_file in
+ prerr_endline "Restoring environment ...";
+ CicEnvironment.restore_from_channel
+ ~callback:(fun uri -> prerr_endline uri) ic;
+ prerr_endline "... done!";
+ close_in ic
+
+ let dump_environment () =
+ let oc = open_out Dsc.environment_file in
+ prerr_endline "Dumping environment ...";
+ CicEnvironment.dump_to_channel
+ ~callback:(fun uri -> prerr_endline uri) oc;
+ prerr_endline "... done!";
+ close_out oc
+
let main () =
try
Sys.catch_break true;
- at_exit (fun () -> unregister_from_broker my_own_id);
+ at_exit (fun () ->
+ if dump_environment_on_exit then
+ dump_environment ();
+ unregister_from_broker my_own_id);
broker_id :=
Some (register_to_broker
my_own_id my_own_url Dsc.hint_type Dsc.description);
+ if Sys.file_exists Dsc.environment_file then
+ restore_environment ();
Http_daemon.start'
~addr:my_own_addr ~port:my_own_port ~mode:`Thread callback
with Sys.Break -> () (* exit nicely, invoking at_exit functions *)