/[mldonkey]/mldonkey/src/daemon/driver/driverMain.ml
ViewVC logotype

Diff of /mldonkey/src/daemon/driver/driverMain.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.48 by spiralvoice, Tue Jul 5 12:27:41 2005 UTC revision 1.49 by spiralvoice, Thu Jul 7 00:25:45 2005 UTC
# Line 22  open Int64ops Line 22  open Int64ops
22  open Printf2  open Printf2
23    
24  open BasicSocket  open BasicSocket
25  open Autoconf      
26  open CommonInteractive  open CommonInteractive
27  open CommonInteractive  open CommonInteractive
28    
# Line 30  open CommonDownloads Line 30  open CommonDownloads
30  open CommonTypes  open CommonTypes
31  open CommonOptions  open CommonOptions
32  open CommonGlobals  open CommonGlobals
33  open CommonNetwork  open CommonNetwork  
 open CommonGraphics  
34        
35  open DriverInterface  open DriverInterface
36    
# Line 86  let second_timer timer = Line 85  let second_timer timer =
85    (try    (try
86        update_link_stats ()        update_link_stats ()
87      with e ->      with e ->
88          lprintf (_b "Exception %s\n") (Printexc2.to_string e));          lprintf_nl (_b "Exception %s") (Printexc2.to_string e));
89            (try            (try
90       CommonUploads.refill_upload_slots ()       CommonUploads.refill_upload_slots ()
91     with e ->     with e ->
92          lprintf (_b "Exception %s\n") (Printexc2.to_string e));          lprintf_nl (_b "Exception %s") (Printexc2.to_string e));
93    CommonUploads.reset_upload_timer ();    CommonUploads.reset_upload_timer ();
94    CommonUploads.shared_files_timer ();    CommonUploads.shared_files_timer ();
95    ()    ()
# Line 101  let start_interfaces () = Line 100  let start_interfaces () =
100    if !!http_port <> 0 then begin try    if !!http_port <> 0 then begin try
101          ignore (DriverControlers.create_http_handler ());          ignore (DriverControlers.create_http_handler ());
102        with e ->        with e ->
103            lprintf (_b "Exception %s while starting HTTP interface\n")            lprintf_nl (_b "Exception %s while starting HTTP interface")
104              (Printexc2.to_string e);              (Printexc2.to_string e);
105      end;      end;
106        
# Line 130  let start_interfaces () = Line 129  let start_interfaces () =
129    
130  let _ =  let _ =
131    CommonWeb.add_web_kind "motd.html" (fun _ filename ->    CommonWeb.add_web_kind "motd.html" (fun _ filename ->
132        lprintf (_b "motd.html changed\n");        lprintf_nl (_b "motd.html changed");
133      motd_html =:= File.to_string filename      motd_html =:= File.to_string filename
134    );    );
135    CommonWeb.add_web_kind "motd.conf" (fun _ filename ->    CommonWeb.add_web_kind "motd.conf" (fun _ filename ->
# Line 148  let _ = Line 147  let _ =
147          | "del_item" ->          | "del_item" ->
148              CommonInteractive.del_item_from_fully_qualified_options name value              CommonInteractive.del_item_from_fully_qualified_options name value
149          | _ ->          | _ ->
150              lprintf (_b "UNUSED LINE: %s\n") line              lprintf_nl (_b "UNUSED LINE: %s") line
151                        
152        done;        done;
153      with      with
154      | End_of_file ->      | End_of_file ->
155          close_in ic          close_in ic
156      | e -> lprintf (_b "Error while reading motd.conf(%s): %s\n") filename      | e -> lprintf_nl (_b "Error while reading motd.conf(%s): %s") filename
157          (Printexc2.to_string e);          (Printexc2.to_string e);
158          close_in ic          close_in ic
159                             );                             );
# Line 187  let save_mlsubmit_reg () = Line 186  let save_mlsubmit_reg () =
186    
187      "admin" "" (Ip.to_string (client_ip None)) !!http_port      "admin" "" (Ip.to_string (client_ip None)) !!http_port
188    in    in
189    File.from_string "mlsubmit.reg" file;    File.from_string (Filename.concat file_basedir "mlsubmit.reg") file;
190            
191  (* Generate the mldonkey_submit file *)  (* Generate the mldonkey_submit file *)
192        
# Line 236  while (my $uri = shift @ARGV) { Line 235  while (my $uri = shift @ARGV) {
235      (Ip.to_string (client_ip None)) !!http_port      (Ip.to_string (client_ip None)) !!http_port
236      "admin" ""      "admin" ""
237    in    in
238    File.from_string "mldonkey_submit" file;    File.from_string (Filename.concat file_basedir "mldonkey_submit") file;
239    try    try
240    Unix.chmod "mldonkey_submit" 0o755    Unix.chmod  (Filename.concat file_basedir "mldonkey_submit") 0o755
241    with    with
242    e -> ()    e -> ()
243    
# Line 266  let load_config () = Line 265  let load_config () =
265    else    else
266      if not exists_users_ini then      if not exists_users_ini then
267        begin        begin
268          lprintf "No config file (users.ini) found. Importing users from downloads.ini.\n";          lprintf_nl "No config file (users.ini) found. Importing users from downloads.ini.";
269          ( try Unix2.copy "downloads.ini" "users.ini" with _ -> () );          ( try Unix2.copy "downloads.ini" "users.ini" with _ -> () );
270        end;        end;
271    
# Line 292  let load_config () = Line 291  let load_config () =
291        Options.load users_ini;        Options.load users_ini;
292  (*      Options.load downloads_expert_ini;       *)  (*      Options.load downloads_expert_ini;       *)
293      with e ->      with e ->
294          lprintf "Exception %s during options load\n" (Printexc2.to_string e);          lprintf_nl "Exception %s during options load" (Printexc2.to_string e);
295          exit 2;          exit 2;
296          ());            ());  
297        
# Line 341  let load_config () = Line 340  let load_config () =
340        
341    Arg.parse ([    Arg.parse ([
342        "-v", Arg.Unit (fun _ ->        "-v", Arg.Unit (fun _ ->
343            lprintf "%s\n" (CommonGlobals.version ());            lprintf_nl "%s" (CommonGlobals.version ());
344            exit 0), _s " : print version number and exit";            exit 0), _s " : print version number and exit";
345        "-exit", Arg.Unit (fun _ -> exit 0), ": exit immediatly";        "-exit", Arg.Unit (fun _ -> exit 0), ": exit immediatly";
346        "-format", Arg.String (fun file ->        "-format", Arg.String (fun file ->
347            let format = CommonMultimedia.get_info file in            let format = CommonMultimedia.get_info file in
348            ()), _s  " <filename> : check file format";            ()), _s  " <filename> : check file format";
349        "-test_ip", Arg.String (fun ip ->        "-test_ip", Arg.String (fun ip ->
350            lprintf "%s = %s\n" ip (Ip.to_string (Ip.of_string ip));            lprintf_nl "%s = %s" ip (Ip.to_string (Ip.of_string ip));
351            exit 0), _s "<ip> : undocumented";            exit 0), _s "<ip> : undocumented";
352        "-check_impl", Arg.Unit (fun _ ->        "-check_impl", Arg.Unit (fun _ ->
353            CommonNetwork.check_network_implementations ();            CommonNetwork.check_network_implementations ();
# Line 356  let load_config () = Line 355  let load_config () =
355            CommonServer.check_server_implementations ();            CommonServer.check_server_implementations ();
356            CommonFile.check_file_implementations ();            CommonFile.check_file_implementations ();
357  (*          CommonResult.check_result_implementations (); *)  (*          CommonResult.check_result_implementations (); *)
358            lprint_newline ();            lprintf_nl "";
359            exit 0),            exit 0),
360        _s " : display information on the implementations";        _s " : display information on the implementations";
361        "-stdout", Arg.Unit (fun _ ->        "-stdout", Arg.Unit (fun _ ->
# Line 371  let load_config () = Line 370  let load_config () =
370         _s ": keep output to stderr after startup";         _s ": keep output to stderr after startup";
371        "-daemon", Arg.Unit (fun _ ->        "-daemon", Arg.Unit (fun _ ->
372            (* Removed due to savannah bug #11514 . *)            (* Removed due to savannah bug #11514 . *)
373            lprintf "\n\nOption -daemon was removed.\nUse 'mlnet > /dev/null 2>&1 &' instead. Exiting...\n";            lprintf_nl "\n\nOption -daemon was removed.\nUse 'mlnet > /dev/null 2>&1 &' instead. Exiting...";
374            exit 0), _s " : this argument was removed, core will exit";            exit 0), _s " : this argument was removed, core will exit";
375        "-find_port", Arg.Set find_other_port,        "-find_port", Arg.Set find_other_port,
376        _s " : find another port when one is already used";        _s " : find another port when one is already used";
# Line 476  http://mldonkey.berlios.de/modules.php?n Line 475  http://mldonkey.berlios.de/modules.php?n
475        if !!recover_temp_on_startup then        if !!recover_temp_on_startup then
476          network_recover_temp r;          network_recover_temp r;
477    );    );
478    lprint_newline ();    lprintf_nl "";
479    lprintf (_b "disabled networks: ");    lprintf (_b "disabled networks: ");
480    let found = ref false in    let found = ref false in
481      networks_iter_all (fun r ->      networks_iter_all (fun r ->
# Line 486  http://mldonkey.berlios.de/modules.php?n Line 485  http://mldonkey.berlios.de/modules.php?n
485              lprintf (_b "%s ") r.network_name              lprintf (_b "%s ") r.network_name
486            end);            end);
487    if not !found then lprintf (_b "none");    if not !found then lprintf (_b "none");
488    lprint_newline ();    lprintf_nl "";
489    CommonOptions.start_running_plugins := true;    CommonOptions.start_running_plugins := true;
490    CommonInteractive.force_download_quotas ();    CommonInteractive.force_download_quotas ();
491        
# Line 534  http://mldonkey.berlios.de/modules.php?n Line 533  http://mldonkey.berlios.de/modules.php?n
533        output_string oc ( Printf.sprintf "%s\n" ( string_of_int ( Unix.getpid () ) ) );        output_string oc ( Printf.sprintf "%s\n" ( string_of_int ( Unix.getpid () ) ) );
534        close_out oc;        close_out oc;
535        CommonGlobals.do_at_exit (fun _ -> Sys.remove "mlnet.pid" );        CommonGlobals.do_at_exit (fun _ -> Sys.remove "mlnet.pid" );
536        if !verbose then lprintf (_b "Starting with pid %s\n") (string_of_int(Unix.getpid ()))        if !verbose then lprintf_nl (_b "Starting with pid %s") (string_of_int(Unix.getpid ()))
537      );      );
538    
539    add_init_hook (fun _ ->    add_init_hook (fun _ ->
# Line 549  http://mldonkey.berlios.de/modules.php?n Line 548  http://mldonkey.berlios.de/modules.php?n
548              Sys.file_exists asker then              Sys.file_exists asker then
549              ignore (Sys.command (Printf.sprintf "%s %s&" asker !!mldonkey_gui));              ignore (Sys.command (Printf.sprintf "%s %s&" asker !!mldonkey_gui));
550          with Not_found ->          with Not_found ->
551              lprintf (_b "Not running under X, not trying to start the GUI\n")              lprintf_nl (_b "Not running under X, not trying to start the GUI")
552              );              );
553    );    );
554    
# Line 558  http://mldonkey.berlios.de/modules.php?n Line 557  http://mldonkey.berlios.de/modules.php?n
557          let new_pw = Unix.getpwnam !!run_as_user  in          let new_pw = Unix.getpwnam !!run_as_user  in
558          MlUnix.setuid new_pw.Unix.pw_uid;          MlUnix.setuid new_pw.Unix.pw_uid;
559          let pw = Unix.getpwuid (Unix.getuid()) in          let pw = Unix.getpwuid (Unix.getuid()) in
560          lprintf (_b "mldonkey is now running as %s\n")  pw.Unix.pw_name;          lprintf_nl (_b "mldonkey is now running as user %s")  pw.Unix.pw_name;
561        with e ->        with e ->
562            lprintf (_b "Exception %s trying to set user_uid [%s]\n")            lprintf_nl (_b "Exception %s trying to set user_uid [%s]")
563            (Printexc2.to_string e) !!run_as_user;            (Printexc2.to_string e) !!run_as_user;
564            exit 2            exit 2
565      end;      end;
# Line 568  http://mldonkey.berlios.de/modules.php?n Line 567  http://mldonkey.berlios.de/modules.php?n
567    if !!run_as_useruid <> 0 then begin    if !!run_as_useruid <> 0 then begin
568        try        try
569          MlUnix.setuid !!run_as_useruid;          MlUnix.setuid !!run_as_useruid;
570          lprintf (_b "mldonkey is now running as uid %d\n")  !!run_as_useruid;          lprintf_nl (_b "mldonkey is now running as uid %d")  !!run_as_useruid;
571        with e ->        with e ->
572            lprintf (_b "Exception %s trying to set user_uid [%d]\n")            lprintf_nl (_b "Exception %s trying to set user_uid [%d]")
573            (Printexc2.to_string e) !!run_as_useruid;            (Printexc2.to_string e) !!run_as_useruid;
574            exit 2            exit 2
575      end;      end;
# Line 581  http://mldonkey.berlios.de/modules.php?n Line 580  http://mldonkey.berlios.de/modules.php?n
580    
581    if Autoconf.system <> "windows" then    if Autoconf.system <> "windows" then
582      MlUnix.set_signal  Sys.sigchld      MlUnix.set_signal  Sys.sigchld
583        (Sys.Signal_handle (fun _ -> lprintf "SIGCHLD\n"));        (Sys.Signal_handle (fun _ -> lprintf_nl "SIGCHLD"));
584    
585    if Autoconf.system <> "windows" then    if Autoconf.system <> "windows" then
586      MlUnix.set_signal  Sys.sighup      MlUnix.set_signal  Sys.sighup
587        (Sys.Signal_handle (fun _ -> lprintf "SIGHUP\n";        (Sys.Signal_handle (fun _ -> lprintf_nl "SIGHUP";
588           BasicSocket.close_all ();           BasicSocket.close_all ();
589           Unix32.close_all ();           Unix32.close_all ();
590           CommonGlobals.print_localtime ();));           CommonGlobals.print_localtime ();));
591    
592    if Autoconf.system <> "windows" then    if Autoconf.system <> "windows" then
593      MlUnix.set_signal  Sys.sigpipe      MlUnix.set_signal  Sys.sigpipe
594        (Sys.Signal_handle (fun _ -> lprintf "SIGPIPE\n"));        (Sys.Signal_handle (fun _ -> lprintf_nl "SIGPIPE"));
595    
596    MlUnix.set_signal  Sys.sigint    MlUnix.set_signal  Sys.sigint
597      (Sys.Signal_handle (fun _ -> lprintf "SIGINT\n";      (Sys.Signal_handle (fun _ -> lprintf_nl "SIGINT";
598          CommonGlobals.exit_properly 0));          CommonGlobals.exit_properly 0));
599    
600    MlUnix.set_signal  Sys.sigterm    MlUnix.set_signal  Sys.sigterm
601      (Sys.Signal_handle (fun _ -> lprintf "SIGTERM\n";      (Sys.Signal_handle (fun _ -> lprintf_nl "SIGTERM";
602          CommonGlobals.exit_properly 0));          CommonGlobals.exit_properly 0));
603    
604    if !verbose then lprintf (_b "Activated system signal handling\n\n");    if !verbose then lprintf_nl (_b "Activated system signal handling\n");
605        
606    Unix32.max_cache_size := MlUnix.max_filedescs    Unix32.max_cache_size := MlUnix.max_filedescs
607    
608  let _ =  let _ =
609    lprintf (_b "Core started");    let security_space_filename = "config_files_space.tmp" in
610      
611      lprintf_nl (_b "Core started");
612    core_included := true;    core_included := true;
613    CommonGlobals.print_localtime ();    CommonGlobals.print_localtime ();
614    
   let security_space_filename = "config_files_space.tmp" in    
615    begin    begin
616  (* Create a 'config_files_security_space' megabytes file to protect some space  (* Create a 'config_files_security_space' megabytes file to protect some space
617  for config files at the end. *)  for config files at the end. *)
# Line 631  for config files at the end. *) Line 631  for config files at the end. *)
631        in        in
632        Unix32.close security_space_fd;        Unix32.close security_space_fd;
633      with _ ->      with _ ->
634          lprintf (_b "Cannot create Security space file:\n");          lprintf_nl (_b "Cannot create Security space file:");
635          lprintf (_b " not enough space on device or bad permissions\n");          lprintf_nl (_b " not enough space on device or bad permissions");
636          lprintf (_b "Exiting...\n");          lprintf_nl (_b "Exiting...");
637          exit 2;          exit 2;
638    end;      end;  
639    CommonGlobals.do_at_exit (fun _ ->    CommonGlobals.do_at_exit (fun _ ->

Legend:
Removed from v.1.48  
changed lines
  Added in v.1.49

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26