mirror of
https://github.com/octoleo/lsyncd.git
synced 2024-10-31 18:52:29 +00:00
cleanups
This commit is contained in:
parent
40a46b6048
commit
b15f1d39d9
76
default.lua
76
default.lua
@ -57,21 +57,26 @@ default.checkgauge = {
|
||||
--
|
||||
-- On default action the user's on*** scripts are called.
|
||||
--
|
||||
default.action = function( inlet )
|
||||
|
||||
default.action = function
|
||||
(
|
||||
inlet -- the inlet of the active sync.
|
||||
)
|
||||
-- in case of moves getEvent returns the origin and dest of the move
|
||||
local event, event2 = inlet.getEvent( )
|
||||
|
||||
local config = inlet.getConfig( )
|
||||
|
||||
local func = config[ 'on'.. event.etype ]
|
||||
|
||||
if type( func ) == 'function' then
|
||||
if type( func ) == 'function'
|
||||
then
|
||||
func( event, event2 )
|
||||
end
|
||||
|
||||
-- if function didnt change the wait status its not interested
|
||||
-- in this event -> drop it.
|
||||
if event.status == 'wait' then
|
||||
if event.status == 'wait'
|
||||
then
|
||||
inlet.discardEvent( event )
|
||||
end
|
||||
|
||||
@ -83,14 +88,20 @@ end
|
||||
--
|
||||
-- Called when collecting a finished child process
|
||||
--
|
||||
default.collect = function( agent, exitcode )
|
||||
|
||||
default.collect = function
|
||||
(
|
||||
agent, -- event or event list being collected
|
||||
exitcode -- the exitcode of the spawned process
|
||||
)
|
||||
local config = agent.config
|
||||
|
||||
local rc
|
||||
|
||||
if config.exitcodes then
|
||||
if config.exitcodes
|
||||
then
|
||||
rc = config.exitcodes[ exitcode ]
|
||||
elseif exitcode == 0 then
|
||||
elseif exitcode == 0
|
||||
then
|
||||
rc = 'ok'
|
||||
else
|
||||
rc = 'die'
|
||||
@ -111,7 +122,6 @@ default.collect = function( agent, exitcode )
|
||||
)
|
||||
|
||||
return 'ok'
|
||||
|
||||
elseif rc == 'again'
|
||||
then
|
||||
if settings( 'insist' )
|
||||
@ -139,7 +149,8 @@ default.collect = function( agent, exitcode )
|
||||
|
||||
terminate( -1 )
|
||||
end
|
||||
elseif rc == 'die' then
|
||||
elseif rc == 'die'
|
||||
then
|
||||
log(
|
||||
'Error',
|
||||
'Failure on startup of ',
|
||||
@ -255,7 +266,10 @@ end
|
||||
-- Called on the Init event sent
|
||||
-- on (re)initialization of Lsyncd for every sync
|
||||
--
|
||||
default.init = function(event)
|
||||
default.init = function
|
||||
(
|
||||
event -- the precreated init event.
|
||||
)
|
||||
local config = event.config
|
||||
|
||||
local inlet = event.inlet
|
||||
@ -264,7 +278,7 @@ default.init = function(event)
|
||||
-- calls a startup if given by user script.
|
||||
if type( config.onStartup ) == 'function'
|
||||
then
|
||||
local startup = config.onStartup(event)
|
||||
config.onStartup( event )
|
||||
-- TODO honor some return codes of startup like "warmstart".
|
||||
end
|
||||
|
||||
@ -279,7 +293,7 @@ end
|
||||
|
||||
--
|
||||
-- The collapsor tries not to have more than these delays.
|
||||
-- So it dealy stack does not grow too large,
|
||||
-- So the delay queue does not grow too large
|
||||
-- since calculation for stacking events is n*log( n ) (or so)
|
||||
--
|
||||
default.maxDelays = 1000
|
||||
@ -339,8 +353,8 @@ default.rsyncExitCodes = {
|
||||
--
|
||||
-- Exitcodes of ssh and what to do.
|
||||
--
|
||||
default.sshExitCodes = {
|
||||
|
||||
default.sshExitCodes =
|
||||
{
|
||||
--
|
||||
-- if another config provides the same table
|
||||
-- this will not be inherited (merged) into that one
|
||||
@ -357,24 +371,25 @@ default.sshExitCodes = {
|
||||
|
||||
|
||||
--
|
||||
-- Minimum seconds between two writes of a status file.
|
||||
-- Minimum seconds between two writes of the status file.
|
||||
--
|
||||
default.statusInterval = 10
|
||||
|
||||
|
||||
--
|
||||
-- checks all keys to be in the checkgauge
|
||||
-- Checks all keys to be in the checkgauge.
|
||||
--
|
||||
|
||||
local function check(
|
||||
local function check
|
||||
(
|
||||
config,
|
||||
gauge,
|
||||
subtable,
|
||||
level
|
||||
)
|
||||
for k, v in pairs( config ) do
|
||||
|
||||
if not gauge[k] then
|
||||
for k, v in pairs( config )
|
||||
do
|
||||
if not gauge[k]
|
||||
then
|
||||
error(
|
||||
'Parameter "'
|
||||
.. subtable
|
||||
@ -385,10 +400,10 @@ local function check(
|
||||
);
|
||||
end
|
||||
|
||||
if type( gauge [ k ] ) == 'table' then
|
||||
|
||||
if type( v ) ~= 'table' then
|
||||
|
||||
if type( gauge [ k ] ) == 'table'
|
||||
then
|
||||
if type( v ) ~= 'table'
|
||||
then
|
||||
error(
|
||||
'Parameter "'
|
||||
.. subtable
|
||||
@ -396,7 +411,6 @@ local function check(
|
||||
.. '" must be a table.',
|
||||
level
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
check(
|
||||
@ -405,12 +419,16 @@ local function check(
|
||||
subtable .. k .. '.',
|
||||
level + 1
|
||||
)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
default.prepare = function( config, level )
|
||||
|
||||
default.prepare = function
|
||||
(
|
||||
config, -- the config to prepare for
|
||||
level -- current callback level for error reporting
|
||||
)
|
||||
|
||||
local gauge = config.checkgauge
|
||||
|
||||
|
@ -1,157 +0,0 @@
|
||||
'\" t
|
||||
.\" Title: lsyncd
|
||||
.\" Author: [see the "AUTHOR" section]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
|
||||
.\" Date: June 2016
|
||||
.\" Manual: Lsyncd
|
||||
.\" Source: Lsyncd 2.1.5
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "LSYNCD" "1" "June 2016" "Lsyncd 2\&.1\&.5" "Lsyncd"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.\" http://bugs.debian.org/507673
|
||||
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * set default formatting
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" disable hyphenation
|
||||
.nh
|
||||
.\" disable justification (adjust text to left margin only)
|
||||
.ad l
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * MAIN CONTENT STARTS HERE *
|
||||
.\" -----------------------------------------------------------------
|
||||
.SH "NAME"
|
||||
lsyncd \- a daemon to continuously synchronize directory trees
|
||||
.SH "SYNOPSIS"
|
||||
.PP
|
||||
config file
|
||||
.RS 4
|
||||
\ \&
|
||||
\fBlsyncd\fR
|
||||
[\fIOPTIONS\fR]
|
||||
\fICONFIG\-FILE\fR
|
||||
.RE
|
||||
.PP
|
||||
default rsync behaviour
|
||||
.RS 4
|
||||
\ \&
|
||||
\fBlsyncd\fR
|
||||
[\fIOPTIONS\fR] \-rsync
|
||||
\fISOURCEDIR\fR\fITARGET\fR
|
||||
\&...
|
||||
.RE
|
||||
.PP
|
||||
default rync+ssh behaviour (moves and deletes through ssh)
|
||||
.RS 4
|
||||
\ \&
|
||||
\fBlsyncd\fR
|
||||
[\fIOPTIONS\fR] \-rsyncssh
|
||||
\fISOURCEDIR\fR\fITARGETHOST\fR\fITARGETDIR\fR
|
||||
\&...
|
||||
.RE
|
||||
.PP
|
||||
default direct behaviour (local file operations/rsync)
|
||||
.RS 4
|
||||
\ \&
|
||||
\fBlsyncd\fR
|
||||
[\fIOPTIONS\fR] \-direct
|
||||
\fISOURCEDIR\fR\fITARGETDIR\fR
|
||||
\&...
|
||||
.RE
|
||||
.SH "DESCRIPTION"
|
||||
.sp
|
||||
Lsyncd(1) watches local directory trees through an event monitor interface (inotify, fsevents)\&. It aggregates and combines events for a few seconds and then spawns one or more processes to synchronize the changes\&. By default this is rsync(1)\&. Lsyncd is thus a light\-weight asynchronous live mirror solution that is comparatively easy to install not requiring new filesystems or block devices and does not hamper local filesystem performance\&.
|
||||
.sp
|
||||
Rsync+ssh is an advanced action configuration that uses a SSH(1) to act file and directory moves directly on the target instead of re\-transmitting the move destination over the wire\&.
|
||||
.sp
|
||||
Fine\-grained customization can be achieved through the CONFIG\-FILE\&. Custom action configs can even be written from scratch in cascading layers ranging from shell scripts to code written in the LUA(1) language\&. This way simplicity can be balanced with powerfulness\&. See the online manual for details on the CONFIG\-FILE https://axkibe\&.github\&.io/lsyncd/config/file/ \&.
|
||||
.sp
|
||||
Note that under normal configuration Lsyncd will delete pre\-existing files in the target directories that are not present in the respective source directory\&.
|
||||
.SH "OPTIONS"
|
||||
.PP
|
||||
\fB\-delay\fR \fISECS\fR
|
||||
.RS 4
|
||||
Overrides the default delay times\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-help\fR
|
||||
.RS 4
|
||||
Show a help message\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-insist\fR
|
||||
.RS 4
|
||||
Continues start up even if rsync cannot connect\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-log\fR \fILEVEL\fR
|
||||
.RS 4
|
||||
Controls which kind of events are logged\&. By default Lsyncd logs
|
||||
\fINormal\fR
|
||||
and
|
||||
\fIError\fR
|
||||
Messages\&.
|
||||
\fB\-log scarce\fR
|
||||
will make Lsyncd log Error messages only\&.
|
||||
\fB\-log all\fR
|
||||
will log all debug messages\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-log\fR \fICategory\fR
|
||||
.RS 4
|
||||
Turns on a specific debug message\&. E\&.g\&.
|
||||
\fB\-log Exec\fR
|
||||
will log all processes as they are spawned\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-nodaemon\fR
|
||||
.RS 4
|
||||
Lsyncd will not detach from the invoker and log as well to stdout/err\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-pidfile\fR \fIFILE\fR
|
||||
.RS 4
|
||||
Lsyncd will write its process ID in
|
||||
\fIFILE\fR\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-runner\fR \fIFILE\fR
|
||||
.RS 4
|
||||
Makes the Lsyncd core load the part of Lsyncd written in Lua from
|
||||
\fIFILE\fR\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-version\fR
|
||||
.RS 4
|
||||
Writes version information and exits\&.
|
||||
.RE
|
||||
.SH "EXIT STATUS"
|
||||
.PP
|
||||
\fB0\fR
|
||||
.RS 4
|
||||
Terminated on a TERM signal(7)
|
||||
.RE
|
||||
.PP
|
||||
\fB\-1\fR
|
||||
.RS 4
|
||||
Failure (syntax, unrecoverable error condition, internal failure)
|
||||
.RE
|
||||
.SH "SEE ALSO"
|
||||
.sp
|
||||
Online Manual: https://axkibe\&.github\&.io/lsyncd/
|
||||
.SH "VERSION"
|
||||
.sp
|
||||
This man page is for lsyncd(1) version 2\&.1\&.5
|
||||
.SH "AUTHOR"
|
||||
.sp
|
||||
Axel Kittenberger, <axkibe@gmail\&.com> 2010\-2016
|
||||
.SH "COPYING"
|
||||
.sp
|
||||
Copyright (C) 2010\-2016 Axel Kittenberger\&. Free use of this software is granted under the terms of the GNU General Public License (GPL) version 2, or any later version\&. Free redistrubition of this Documentation (/doc directory) is granted under the terms of the Creative Commons 3\&.0 Attribution License (CC\-3\&.0\-BY)\&.
|
800
lsyncd.lua
800
lsyncd.lua
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user