introducing --stubborn, to startup regardless if startup rsyncs work or not.\nsmall fixes

This commit is contained in:
Axel Kittenberger 2008-12-13 17:30:52 +00:00
parent 5c9785b32e
commit fa40f4c1c0
4 changed files with 50 additions and 15 deletions

View File

@ -31,10 +31,10 @@ lsyncd.conf.xml.5: manpage.lsyncd.conf.xml
$(XP) $(DB2MAN) $< $(XP) $(DB2MAN) $<
AM_CFLAGS=-Wall AM_CFLAGS=-Wall
AM_LIBS= AM_LDFLAGS=
if XML_CONFIG if XML_CONFIG
DEFS+=-DXML_CONFIG DEFS+=-DXML_CONFIG
AM_CFLAGS += `xml2-config --cflags` AM_CFLAGS += `xml2-config --cflags`
AM_CFLAGS += `xml2-config --libs` AM_LDFLAGS += `xml2-config --libs`
endif endif

View File

@ -195,6 +195,14 @@ int flag_dryrun = 0;
*/ */
int flag_nodaemon = 0; int flag_nodaemon = 0;
/**
* Global Option: if true, ignore rsync errors on startup.
* (during normal operations they have to be ignored eitherway,
* since rsync may also fail due e.g. the directory already
* beeing deleted when lsyncd wants to sync it.)
*/
int flag_stubborn = 0;
/** /**
* Global Option: pidfile, which holds the PID of the running daemon process. * Global Option: pidfile, which holds the PID of the running daemon process.
*/ */
@ -851,7 +859,7 @@ bool buildpath(char *pathname,
} }
strcat(pathname, dirname); strcat(pathname, dirname);
} }
printlogf(LOG_NORMAL, " BUILDPATH(%d, %s, %s) -> %s", watch, dirname, prefix, pathname); printlogf(LOG_DEBUG, " BUILDPATH(%d, %s, %s) -> %s", watch, dirname, prefix, pathname);
return true; return true;
} }
@ -1231,6 +1239,7 @@ void print_help(char *arg0)
printf(" --no-daemon Do not detach, log to stdout/stderr\n"); printf(" --no-daemon Do not detach, log to stdout/stderr\n");
printf(" --pidfile FILE Create a file containing pid of the daemon\n"); printf(" --pidfile FILE Create a file containing pid of the daemon\n");
printf(" --scarce Only log errors\n"); printf(" --scarce Only log errors\n");
printf(" --stubborn Ignore rsync errors on startup.\n");
printf(" --version Print version an exit.\n"); printf(" --version Print version an exit.\n");
printf("\n"); printf("\n");
printf("Take care that lsyncd is allowed to write to the logfile specified.\n"); printf("Take care that lsyncd is allowed to write to the logfile specified.\n");
@ -1424,6 +1433,8 @@ bool parse_settings(xmlNodePtr node) {
loglevel = 3; loglevel = 3;
} else if (!xmlStrcmp(snode->name, BAD_CAST "no-daemon")) { } else if (!xmlStrcmp(snode->name, BAD_CAST "no-daemon")) {
flag_nodaemon = 1; flag_nodaemon = 1;
} else if (!xmlStrcmp(snode->name, BAD_CAST "stubborn")) {
flag_stubborn = 1;
} else { } else {
fprintf(stderr, "error unknown node in <settings> \"%s\"", snode->name); fprintf(stderr, "error unknown node in <settings> \"%s\"", snode->name);
exit(LSYNCD_BADCONFIGFILE); exit(LSYNCD_BADCONFIGFILE);
@ -1508,7 +1519,8 @@ bool parse_options(int argc, char **argv)
{"logfile", 1, NULL, 0}, {"logfile", 1, NULL, 0},
{"no-daemon", 0, &flag_nodaemon, 1}, {"no-daemon", 0, &flag_nodaemon, 1},
{"pidfile", 1, NULL, 0}, {"pidfile", 1, NULL, 0},
{"scarce", 0, &loglevel, 3}, {"scarce", 0, &loglevel, 3},
{"stubborn", 0, &flag_stubborn, 1},
{"version", 0, NULL, 0}, {"version", 0, NULL, 0},
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
@ -1784,9 +1796,12 @@ int main(int argc, char **argv)
char **target; char **target;
for (target = dir_confs[i].targets; *target; ++target) { for (target = dir_confs[i].targets; *target; ++target) {
if (!action(&dir_confs[i], dir_confs[i].source, *target, true)) { if (!action(&dir_confs[i], dir_confs[i].source, *target, true)) {
printlogf(LOG_ERROR, "Initial rsync from %s to %s failed", printlogf(LOG_ERROR, "Initial rsync from %s to %s failed%s",
dir_confs[i].source, *target); dir_confs[i].source, *target,
exit(LSYNCD_EXECFAIL); flag_stubborn ? ", but continuing because being stubborn." : ".");
if (!flag_stubborn) {
exit(LSYNCD_EXECFAIL);
}
} }
} }
} }

View File

@ -84,22 +84,34 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
<title>SETTINGS</title> <title>SETTINGS</title>
<para>Next is optionally a <option>&lt;settings&gt;</option> node. It controls lsyncd global settings. All settings are optional.</para> <para>Next is optionally a <option>&lt;settings&gt;</option> node. It controls lsyncd global settings. All settings are optional.</para>
<programlisting> &lt;settings&gt;</programlisting> <programlisting> &lt;settings&gt;</programlisting>
<para>If a <option>&lt;debug/&gt;</option> node is present all debug messages will be logged. Default is a normal verbosity.</para> <para>If a <option>&lt;debug/&gt;</option> node is present all debug messages will be logged. Default is a normal verbosity.</para>
<programlisting> &lt;debug/&gt;</programlisting> <programlisting> &lt;debug/&gt;</programlisting>
<para>If a <option>&lt;scarce&gt;</option> node is present only error messages will be logged. Default is a normal verbosity.</para> <para>If a <option>&lt;scarce&gt;</option> node is present only error messages will be logged. Default is a normal verbosity.</para>
<programlisting> &lt;scarce/&gt;</programlisting> <programlisting> &lt;scarce/&gt;</programlisting>
<para>If a <option>&lt;stubborn&gt;</option> node is present lsyncd will continue even if the startup sync fails. Default is being not stubborn.</para>
<programlisting> &lt;stubborn/&gt;</programlisting>
<para>If a <option>&lt;no-daemon&gt;</option> node is present lsyncd will not detach and log to stdout/stderr. Default is to detach as daemon.</para> <para>If a <option>&lt;no-daemon&gt;</option> node is present lsyncd will not detach and log to stdout/stderr. Default is to detach as daemon.</para>
<programlisting> &lt;no-daemon/&gt;</programlisting> <programlisting> &lt;no-daemon/&gt;</programlisting>
<para>If a <option>&lt;dry-run&gt;</option> node is present lsyncd will not call any actions (rsync) for test purposes. Default is not to run dry.</para> <para>If a <option>&lt;dry-run&gt;</option> node is present lsyncd will not call any actions (rsync) for test purposes. Default is not to run dry.</para>
<programlisting> &lt;dry-run/&gt;</programlisting> <programlisting> &lt;dry-run/&gt;</programlisting>
<para>With an <option>&lt;exclude-from&gt;</option> entry an exclusion file can be specified with a &quot;filename&quot; parameter. This will be passed to rsync and follows rsyncs grammar for exclude files. Default is not to pass an exlude file to rsync.</para> <para>With an <option>&lt;exclude-from&gt;</option> entry an exclusion file can be specified with a &quot;filename&quot; parameter. This will be passed to rsync and follows rsyncs grammar for exclude files. Default is not to pass an exlude file to rsync.</para>
<programlisting> &lt;exclude-from filename=&quot;/etc/lsyncd.exclude&quot;/&gt;</programlisting> <programlisting> &lt;exclude-from filename=&quot;/etc/lsyncd.exclude&quot;/&gt;</programlisting>
<para>With a <option>&lt;logfile&gt;</option> node to location of the logfile can be changed. Default is <filename>/var/log/lsyncd</filename>. Take care that the user which lsyncd is running with can write to this file.</para> <para>With a <option>&lt;logfile&gt;</option> node to location of the logfile can be changed. Default is <filename>/var/log/lsyncd</filename>. Take care that the user which lsyncd is running with can write to this file.</para>
<programlisting> &lt;logfile filename=&quot;/var/log/lsyncd&quot;/&gt;</programlisting> <programlisting> &lt;logfile filename=&quot;/var/log/lsyncd&quot;/&gt;</programlisting>
<para>A <option>&lt;binary&gt;</option> node specifies the binary lsyncd will call to sync stuff. Usually you want this to be rsync. Default is <filename>/usr/bin/rsync</filename>.</para> <para>A <option>&lt;binary&gt;</option> node specifies the binary lsyncd will call to sync stuff. Usually you want this to be rsync. Default is <filename>/usr/bin/rsync</filename>.</para>
<programlisting> &lt;binary filename=&quot;/usr/bin/rsync&quot;/&gt;</programlisting> <programlisting> &lt;binary filename=&quot;/usr/bin/rsync&quot;/&gt;</programlisting>
<para>If a <option>&lt;pidfile&gt;</option> node is present lsyncd will write its pid there. Default is not to write a pidfile.</para> <para>If a <option>&lt;pidfile&gt;</option> node is present lsyncd will write its pid there. Default is not to write a pidfile.</para>
<programlisting> &lt;pidfile filename=&quot;/var/run/lsyncd.pid&quot;/&gt;</programlisting> <programlisting> &lt;pidfile filename=&quot;/var/run/lsyncd.pid&quot;/&gt;</programlisting>
<para>With a <option>&lt;callopts&gt;</option> node you can control the arguments lsyncd will call the &lt;binary&gt; (rsync) with. Each child node will specify one argument. &lt;option&gt; specifies a literal argument. Only %r will be replaced with 'r' when rsycnd is supposed to work recursive (on startup of lsyncd) or 'd' on normal operations. &lt;exclude-file&gt; will be replaced with <option>--exclude-from [FILE]</option> if an &lt;exclude-from&gt; file is specified. &lt;source&gt; will be replaced the source directory to sync from. &lt;destination&gt; will be replace to the target to sync to. Default arguments are <option>-lt%r --delete {--exclude-from [FILE]} [SOURCE] [DIRECTORY]</option>.</para> <para>With a <option>&lt;callopts&gt;</option> node you can control the arguments lsyncd will call the &lt;binary&gt; (rsync) with. Each child node will specify one argument. &lt;option&gt; specifies a literal argument. Only %r will be replaced with 'r' when rsycnd is supposed to work recursive (on startup of lsyncd) or 'd' on normal operations. &lt;exclude-file&gt; will be replaced with <option>--exclude-from [FILE]</option> if an &lt;exclude-from&gt; file is specified. &lt;source&gt; will be replaced the source directory to sync from. &lt;destination&gt; will be replace to the target to sync to. Default arguments are <option>-lt%r --delete {--exclude-from [FILE]} [SOURCE] [DIRECTORY]</option>.</para>
<programlisting> &lt;callopts&gt; <programlisting> &lt;callopts&gt;
&lt;option text=&quot;-lt%r&quot;/&gt; &lt;option text=&quot;-lt%r&quot;/&gt;

View File

@ -91,15 +91,16 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
<cmdsynopsis> <cmdsynopsis>
<command>&dhpackage;</command> <command>&dhpackage;</command>
<!-- These are several examples, how syntaxes could look --> <!-- These are several examples, how syntaxes could look -->
<arg choice="opt"><option>--binary <parameter>FILE</parameter></option></arg>
<arg choice="opt"><option>--conf <parameter>FILE</parameter></option></arg> <arg choice="opt"><option>--conf <parameter>FILE</parameter></option></arg>
<arg choice="opt"><option>--debug</option></arg> <arg choice="opt"><option>--debug</option></arg>
<arg choice="opt"><option>--dryrun</option></arg> <arg choice="opt"><option>--dryrun</option></arg>
<arg choice="opt"><option>--exclude-file <parameter>FILE</parameter></option></arg> <arg choice="opt"><option>--exclude-file <parameter>FILE</parameter></option></arg>
<arg choice="opt"><option>--logfile <parameter>FILE</parameter></option></arg> <arg choice="opt"><option>--logfile <parameter>FILE</parameter></option></arg>
<arg choice="opt"><option>--no-daemon</option></arg> <arg choice="opt"><option>--no-daemon</option></arg>
<arg choice="opt"><option>--binary <parameter>FILE</parameter></option></arg>
<arg choice="opt"><option>--pidfile <parameter>FILE</parameter></option></arg> <arg choice="opt"><option>--pidfile <parameter>FILE</parameter></option></arg>
<arg choice="opt"><option>--scarce</option></arg> <arg choice="opt"><option>--scarce</option></arg>
<arg choice="opt"><option>--stubborn</option></arg>
<arg choice="opt"><replaceable>source</replaceable></arg> <arg choice="opt"><replaceable>source</replaceable></arg>
<arg choice="opt"><replaceable>target...</replaceable></arg> <arg choice="opt"><replaceable>target...</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
@ -139,6 +140,13 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
<!-- Use the variablelist.term.separator and the <!-- Use the variablelist.term.separator and the
variablelist.term.break.after parameters to variablelist.term.break.after parameters to
control the term elements. --> control the term elements. -->
<varlistentry>
<term><option>--binary <parameter>FILE</parameter></option></term>
<listitem>
<para>Call this binary to sync (DEFAULT: /usr/bin/rsync).</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>--conf <parameter>FILE</parameter></option></term> <term><option>--conf <parameter>FILE</parameter></option></term>
<listitem> <listitem>
@ -183,13 +191,6 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>--rsync-binary <parameter>FILE</parameter></option></term>
<listitem>
<para>Call this binary to sync (DEFAULT: /usr/bin/rsync).</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>--pidfile <parameter>FILE</parameter></option></term> <term><option>--pidfile <parameter>FILE</parameter></option></term>
<listitem> <listitem>
@ -203,6 +204,13 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
<para>Only log errors.</para> <para>Only log errors.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>--stubborn</option></term>
<listitem>
<para>Continue even if startup sync fails.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>--help</option></term> <term><option>--help</option></term>