Add --exit-on-nosync option.
authorDavid E. Wheeler <david@justatheory.com>
Tue, 16 Oct 2012 23:11:55 +0000 (16:11 -0700)
committerDavid E. Wheeler <david@justatheory.com>
Tue, 16 Oct 2012 23:11:55 +0000 (16:11 -0700)
And change the default so that, if there are no active syncs, by default
bucardo will *not* exit. Pass this option to make it exit anyway. Per
discussion; Closes #8

Bucardo.pm
bucardo

index 68a79035ce80aaa669a432d690ddd35b2aab59f0..de6678b433aff6f8d731b79246b79e21da0dee31 100644 (file)
@@ -204,6 +204,7 @@ sub new {
         version      => $VERSION,
         listening    => {},
         pidmap       => {},
+        exit_on_nosync => 0,
         sqlprefix    => "/* Bucardo $VERSION */",
     };
 
@@ -631,8 +632,8 @@ sub start_mcp {
     ## This resets listeners, kills kids, and loads/activates syncs
     my $active_syncs = $self->reload_mcp();
 
-    ## No syncs means no reason for us to hang around, so we exit
-    if (!$active_syncs) {
+    if (!$active_syncs && $self->{exit_on_nosync}) {
+        ## No syncs means no reason for us to hang around, so we exit
         $self->glog('No active syncs were found, so we are exiting', LOG_WARN);
         $self->db_notify($masterdbh, 'nosyncs', 1);
         $self->cleanup_mcp('No active syncs');
diff --git a/bucardo b/bucardo
index 9902a5d675987966d4e44a22c74eff319dac2cc4..2a345a902743b3f2a2f1316d1af373e7dbc1fcec 100755 (executable)
--- a/bucardo
+++ b/bucardo
@@ -143,6 +143,7 @@ GetOptions ## no critic (ProhibitCallsToUndeclaredSubs)
      'dryrun|dry-run',
      'confirm',
      'tsep=s',
+     'exit-on-nosync!',
 
      ## These are sent to the constructor:
      'bcverbose',
@@ -904,6 +905,8 @@ sub start {
 
     ## Create a new Bucardo daemon
     require Bucardo;
+    $bcargs->{exit_on_nosync} = delete $bcargs->{'exit-on-nosync'}
+        if exists $bcargs->{'exit-on-nosync'};
     my $bc = Bucardo->new($bcargs);
 
     ## Verify that the version of Bucardo.pm matches our version
@@ -9568,6 +9571,19 @@ before the name as well, so a debugname of "rootdb" would produce a log file nam
 
 Forces removal of all old debug files before running.
 
+=item B<--exit-on-nosync>
+
+=item B<--no-exit-on-nosync>
+
+On startup, if Bucardo finds no active syncs, it normally will continue to
+run, requiring a restart once syncs are added. This is useful for startup
+scripts and whatnot.
+
+If, however, you want it to exit when there are no active syncs, pass the
+C<--exit-on-nosync> option. You can also be explicit that it should I<not>
+exit when there are no syncs by passing C<--no-exit-on-nosync>. This is the
+default value.
+
 =back
 
 =head1 FILES