我已经安装观察者这样:和都watcher.py
位于watcher.ini
我/etc
也安装了pyinotify
,当我使用时它确实有效python -m pyinotify -v /var/www
但是,我想使用守护进程,当我启动时watcher.py
,我的电脑上出现了奇怪的线条watcher.log
(见下文)。我还包含了我的watcher.ini
文件。
注意:我使用的是最新版本的 Python。watcher.py 可以在以下位置找到:这里
我的做法有什么问题?另外,我真的需要 pyinotify 吗?非常感谢你的帮助
观察者.ini:
[DEFAULT]
logfile=/var/log/watcher.log
pidfile=/var/run/watcher.pid
[job1]
watch=/var/www
events=create,delete,modify
recursive=true
command=mkdir /home/mockfolder ## just using this as test
观察者日志:
2012-09-22 04:28:23.822029 Daemon started
2012-09-22 04:28:23.822596 job1: /var/www
Traceback (most recent call last):
File "/etc/watcher.py", line 359, in <module>
daemon.start()
File "/etc/watcher.py", line 124, in start
self.run()
File "/etc/watcher.py", line 256, in run
autoadd = self.config.getboolean(section,'autoadd')
File "/usr/lib/python2.7/ConfigParser.py", line 368, in getboolean
v = self.get(section, option)
File "/usr/lib/python2.7/ConfigParser.py", line 618, in get
raise NoOptionError(option, section)
ConfigParser.NoOptionError: No option 'autoadd' in section: 'job1'
答案1
ConfigParser.NoOptionError: No option 'autoadd' in section: 'job1'
据我所知,autoadd
选项是必需的。如果您不想监视新的子目录,可以将其设置为 false:
; if true, watcher will automatically watch new subdirectory
autoadd=false
/tmp/watcher.log
:
2012-09-23 22:30:33.934975 Daemon started
2012-09-23 22:30:33.935313 job1: /tmp
ps -ef | grep [w]atcher
quanta 19813 1 0 22:30 ? 00:00:00 /usr/bin/python2.7 ./watcher.py start --config watcher.ini