mirror of https://github.com/octoleo/lsyncd.git
introducing --stubborn, to startup regardless if startup rsyncs work or not.\nsmall fixes
This commit is contained in:
parent
5c9785b32e
commit
fa40f4c1c0
|
@ -31,10 +31,10 @@ lsyncd.conf.xml.5: manpage.lsyncd.conf.xml
|
|||
$(XP) $(DB2MAN) $<
|
||||
|
||||
AM_CFLAGS=-Wall
|
||||
AM_LIBS=
|
||||
AM_LDFLAGS=
|
||||
if XML_CONFIG
|
||||
DEFS+=-DXML_CONFIG
|
||||
AM_CFLAGS += `xml2-config --cflags`
|
||||
AM_CFLAGS += `xml2-config --libs`
|
||||
AM_LDFLAGS += `xml2-config --libs`
|
||||
endif
|
||||
|
||||
|
|
25
lsyncd.c
25
lsyncd.c
|
@ -195,6 +195,14 @@ int flag_dryrun = 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.
|
||||
*/
|
||||
|
@ -851,7 +859,7 @@ bool buildpath(char *pathname,
|
|||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1231,6 +1239,7 @@ void print_help(char *arg0)
|
|||
printf(" --no-daemon Do not detach, log to stdout/stderr\n");
|
||||
printf(" --pidfile FILE Create a file containing pid of the daemon\n");
|
||||
printf(" --scarce Only log errors\n");
|
||||
printf(" --stubborn Ignore rsync errors on startup.\n");
|
||||
printf(" --version Print version an exit.\n");
|
||||
printf("\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;
|
||||
} else if (!xmlStrcmp(snode->name, BAD_CAST "no-daemon")) {
|
||||
flag_nodaemon = 1;
|
||||
} else if (!xmlStrcmp(snode->name, BAD_CAST "stubborn")) {
|
||||
flag_stubborn = 1;
|
||||
} else {
|
||||
fprintf(stderr, "error unknown node in <settings> \"%s\"", snode->name);
|
||||
exit(LSYNCD_BADCONFIGFILE);
|
||||
|
@ -1508,7 +1519,8 @@ bool parse_options(int argc, char **argv)
|
|||
{"logfile", 1, NULL, 0},
|
||||
{"no-daemon", 0, &flag_nodaemon, 1},
|
||||
{"pidfile", 1, NULL, 0},
|
||||
{"scarce", 0, &loglevel, 3},
|
||||
{"scarce", 0, &loglevel, 3},
|
||||
{"stubborn", 0, &flag_stubborn, 1},
|
||||
{"version", 0, NULL, 0},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
@ -1784,9 +1796,12 @@ int main(int argc, char **argv)
|
|||
char **target;
|
||||
for (target = dir_confs[i].targets; *target; ++target) {
|
||||
if (!action(&dir_confs[i], dir_confs[i].source, *target, true)) {
|
||||
printlogf(LOG_ERROR, "Initial rsync from %s to %s failed",
|
||||
dir_confs[i].source, *target);
|
||||
exit(LSYNCD_EXECFAIL);
|
||||
printlogf(LOG_ERROR, "Initial rsync from %s to %s failed%s",
|
||||
dir_confs[i].source, *target,
|
||||
flag_stubborn ? ", but continuing because being stubborn." : ".");
|
||||
if (!flag_stubborn) {
|
||||
exit(LSYNCD_EXECFAIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,22 +84,34 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
|
|||
<title>SETTINGS</title>
|
||||
<para>Next is optionally a <option><settings></option> node. It controls lsyncd global settings. All settings are optional.</para>
|
||||
<programlisting> <settings></programlisting>
|
||||
|
||||
<para>If a <option><debug/></option> node is present all debug messages will be logged. Default is a normal verbosity.</para>
|
||||
<programlisting> <debug/></programlisting>
|
||||
|
||||
<para>If a <option><scarce></option> node is present only error messages will be logged. Default is a normal verbosity.</para>
|
||||
<programlisting> <scarce/></programlisting>
|
||||
|
||||
<para>If a <option><stubborn></option> node is present lsyncd will continue even if the startup sync fails. Default is being not stubborn.</para>
|
||||
<programlisting> <stubborn/></programlisting>
|
||||
|
||||
<para>If a <option><no-daemon></option> node is present lsyncd will not detach and log to stdout/stderr. Default is to detach as daemon.</para>
|
||||
<programlisting> <no-daemon/></programlisting>
|
||||
|
||||
<para>If a <option><dry-run></option> node is present lsyncd will not call any actions (rsync) for test purposes. Default is not to run dry.</para>
|
||||
<programlisting> <dry-run/></programlisting>
|
||||
|
||||
<para>With an <option><exclude-from></option> entry an exclusion file can be specified with a "filename" 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> <exclude-from filename="/etc/lsyncd.exclude"/></programlisting>
|
||||
|
||||
<para>With a <option><logfile></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> <logfile filename="/var/log/lsyncd"/></programlisting>
|
||||
|
||||
<para>A <option><binary></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> <binary filename="/usr/bin/rsync"/></programlisting>
|
||||
|
||||
<para>If a <option><pidfile></option> node is present lsyncd will write its pid there. Default is not to write a pidfile.</para>
|
||||
<programlisting> <pidfile filename="/var/run/lsyncd.pid"/></programlisting>
|
||||
|
||||
<para>With a <option><callopts></option> node you can control the arguments lsyncd will call the <binary> (rsync) with. Each child node will specify one argument. <option> 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. <exclude-file> will be replaced with <option>--exclude-from [FILE]</option> if an <exclude-from> file is specified. <source> will be replaced the source directory to sync from. <destination> will be replace to the target to sync to. Default arguments are <option>-lt%r --delete {--exclude-from [FILE]} [SOURCE] [DIRECTORY]</option>.</para>
|
||||
<programlisting> <callopts>
|
||||
<option text="-lt%r"/>
|
||||
|
|
|
@ -91,15 +91,16 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
|
|||
<cmdsynopsis>
|
||||
<command>&dhpackage;</command>
|
||||
<!-- 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>--debug</option></arg>
|
||||
<arg choice="opt"><option>--dryrun</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>--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>--scarce</option></arg>
|
||||
<arg choice="opt"><option>--stubborn</option></arg>
|
||||
<arg choice="opt"><replaceable>source</replaceable></arg>
|
||||
<arg choice="opt"><replaceable>target...</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
|
@ -139,6 +140,13 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
|
|||
<!-- Use the variablelist.term.separator and the
|
||||
variablelist.term.break.after parameters to
|
||||
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>
|
||||
<term><option>--conf <parameter>FILE</parameter></option></term>
|
||||
<listitem>
|
||||
|
@ -183,13 +191,6 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
|
|||
</listitem>
|
||||
</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>
|
||||
<term><option>--pidfile <parameter>FILE</parameter></option></term>
|
||||
<listitem>
|
||||
|
@ -203,6 +204,13 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
|
|||
<para>Only log errors.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--stubborn</option></term>
|
||||
<listitem>
|
||||
<para>Continue even if startup sync fails.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--help</option></term>
|
||||
|
|
Loading…
Reference in New Issue