Author: sparky
Date: Tue Nov  3 23:58:55 2009
New Revision: 10941

Modified:
   toys/rsget.pl/RSGet/Main.pm
Log:
- use Proc::Daemon for daemonizing
- fixed http server in daemon mode


Modified: toys/rsget.pl/RSGet/Main.pm
==============================================================================
--- toys/rsget.pl/RSGet/Main.pm (original)
+++ toys/rsget.pl/RSGet/Main.pm Tue Nov  3 23:58:55 2009
@@ -20,6 +20,7 @@
 use RSGet::Tools;
 use RSGet::Wait;
 use Time::HiRes;
+use Cwd;
 set_rev qq$Id$;
 
 def_settings(
@@ -42,6 +43,7 @@
        userconfig => {
                desc => "User configuration file.",
                allowed => qr/.+/,
+               type => "PATH",
        },
        daemon => {
                desc => "Enter daemon mode. 1 - disable console output, 2 - 
also fork",
@@ -72,29 +74,29 @@
        RSGet::Line::init( $daemon );
        print_settings() if verbose( 1 );
        RSGet::FileList::set_file();
-       maybe_start_http();
        set_interfaces( $ifs );
 
        new RSGet::Line();
 
        find_getters();
 
-       new RSGet::Line();
-       new RSGet::Line( "rsget.pl started successfully" );
-       new RSGet::Line();
-       RSGet::Line::update();
 
        if ( $daemon == 2 ) {
-               my $pid = fork();
-               die "Cannot fork" unless defined $pid;
-               if ( $pid ) {
-                       print "rsget.pl daemon started on pid: $pid\n";
-                       exit 0;
-               }
+               my $start_dir = getcwd();
+               require Proc::Daemon;
+               print "starting rsget.pl daemon\n" if verbose( 1 );
+               Proc::Daemon::Init();
+               chdir $start_dir;
        } elsif ( $daemon ) {
                print "rsget.pl daemon started successfully\n";
        }
 
+       maybe_start_http();
+       new RSGet::Line();
+       new RSGet::Line( "rsget.pl started successfully" );
+       new RSGet::Line();
+       RSGet::Line::update();
+
        loop();
 }
 
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to