added checking of result when building demos
[urisagit/Stem.git] / Design / logtail_notes
CommitLineData
4536f655 1
2 Stem::LogTail Design Notes
3
4The Stem::LogTail module provides a service similar to the standard Unix
5program tail -f. It constructs a Cell that can watch a file for changes
6in it size or inode and then sends the new data to a destination. The
7destination is a Logical Log created elsewhere in the Stem application
8and it can be located on any Hub on the network. Also file status
9changes such as not being found, first time it is opened, it was
10truncated, etc. can be sent to a different Logical Log than the data.
11This module is a critical part of the StemLog application which
12transfers active log files from one system to another.
13
14The action of checking the file is triggered by a call to the tail_cmd
15method. There are two main ways of triggering it, either by an internal
16timer or via a command message directed at this Cell. The timer is
17configured when the Cell is created and its resolution in in seconds. So
18e.g. you can cause a file check to occur every 15 seconds. If a 'tail'
19command message is sent to this Cell, it will also trigger a file
20check. The command message is usually sent from a Stem::Cron entry
21configured elsewhere. In either case new data is sent to the 'data_log'
22Log and status is sent to the 'status_log' Log.
23
24The primary configuration parameter is the path to the file to be
25checked. Also the required 'data_log', optional 'status_log' and
26'repeat_interval' are set in the configuration.
27
28When the file is checked, the current size and inode are compared to the
29previous values. If either has changed, then either data and/or status log
30entries are sent.
31
32NOTE: The modification time of a file is not currently checked for
33changes. The reason is that there is no way to determine if a file
34changed (or what data has changed) if the file just has its modification
35time changed (by touch or utime). This means that there is a weakness in
36just checking for the file size changing. If a file were to be truncated
37and then written to with the same amount of data as it had when it was
38last checked, a tail operation would not report any new data. This bug
39exists in both the GNU and Solaris tail programs. The only way around
40this is to check for modification time changes and trust
41this. Stem::LogTail will support an option for doing this instead of
42checking file size but it is up to the user to assure that the file will
43only change its modification time if its data actually changes. Most
44logs generated by programs have this attribute.