X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=main.ml;h=872dc5959adc02bac53fbd09b3b2ae6e74fe4a7f;hb=26326ab885a36f7e0661703b735109df36520b30;hp=a70a473f691d599d8f1f771682cd5030f81850a7;hpb=16c8bb31dd971b7fab00dbb17a75bb08cee463c6;p=vsys.git diff --git a/main.ml b/main.ml index a70a473..872dc59 100644 --- a/main.ml +++ b/main.ml @@ -16,42 +16,49 @@ let cmdspeclist = ("-daemon",Arg.Set(daemonize), "Daemonize"); ("-conffile",Arg.Set_string(Globals.conffile), "Config file"); ("-backend",Arg.Set_string(Globals.backend), "Backend directory"); - ("-frontend",Arg.Tuple[Arg.String(fun s->cur_dir:=s);Arg.String(fun s->cur_slice:=s;input_file_list:=(!cur_dir,!cur_slice)::!input_file_list)], "frontendN,slicenameN"); - ("-nochroot",Arg.Set(Globals.nochroot), "Run in non-chroot environment") + ("-frontend",Arg.Tuple[Arg.String(fun s->cur_dir:=s); + Arg.String(fun s->cur_slice:=s; + input_file_list:=(!cur_dir,!cur_slice)::!input_file_list)], + "frontendN,slicenameN"); + ("-nochroot",Arg.Set(Globals.nochroot), "Run in non-chroot environment"); + ("-failsafe",Arg.Set(Globals.failsafe), "Never crash. Be stupid, but never crash. Use at your own risk."); ] -let cont = ref true - let _ = - printf "Vsys v%s\n" Globals.vsys_version;flush stdout; + logprint "Starting Vsys v%s\n" Globals.vsys_version; + print "Starting Vsys v%s\n" Globals.vsys_version; Arg.parse cmdspeclist (fun x->()) "Usage: vsys "; if (!Globals.backend == "") then - printf "Try vsys --help\n" + printf "Try vsys --help\n" else begin if (!daemonize) then begin - printf "Daemonizing\n";flush Pervasives.stdout; - let child = Unix.fork () in - if (child <> 0) then - begin + print "Daemonizing\n"; + let child = Unix.fork () in + if (child <> 0) then + begin let pidfile = open_out !Globals.pid_filepath in fprintf pidfile "%d" child; - close_out pidfile; - exit(0) - end - end; + close_out pidfile; + exit(0) + end + end; - Dirwatcher.initialize (); - Directfifowatcher.initialize (); + Dirwatcher.initialize (); + Directfifowatcher.initialize (); - if (!Globals.conffile <> "") then - begin - let frontends = Conffile.read_frontends !Globals.conffile in - input_file_list:=List.concat [!input_file_list;frontends] - end; + if (!Globals.conffile <> "") then + begin + let frontends = Conffile.read_frontends !Globals.conffile in + input_file_list:=List.concat [!input_file_list;frontends] + end; - let felst = List.map (fun lst->let (x,y)=lst in printf "Slice %s (%s)\n" x y;flush logfd;new frontendHandler lst) !input_file_list in - let _ = new backendHandler !Globals.backend felst in - Fdwatcher.start_watch () + let felst = List.map + (fun lst->let (x,y)=lst in + logprint "Slice %s (%s)\n" x y; + new frontendHandler lst) + !input_file_list in + let _ = new backendHandler !Globals.backend felst in + Fdwatcher.start_watch () end