我有一个Guard设置(对文件系统事件作出反应的Ruby gem - https://github.com/guard/),它将咖啡文件编译为Javascript,并在更改相关js文件时重新启动node.js服务器。
这是我项目目录中的Guardfile:
guard 'process',
:name => 'SPCRM Server',
:command => 'node --debug server/js/app.js' do
watch(%r{^server/js/.+\.js$})
end
guard 'coffeescript',
:input => 'app/coffee',
:output => 'app/js'
guard 'coffeescript',
:input => 'server/coffee',
:output => 'server/js'
当我更改相关的.coffee文件(以便更新服务器/ js /文件)时,该过程重新启动两次。手动修改server / js / * .js文件,它只重启一次(如预期的那样),让我相信它会因为某些原因而进行两次传递。
以下是使用 guard -d
运行的输出debugger listening on port 5858DEBUG (19:30:26): Guard::CoffeeScript#run_on_change with ["server/coffee/app.coffee"]
DEBUG (19:30:26): Hook :run_on_change_begin executed for Guard::CoffeeScript
DEBUG (19:30:26): Command execution: command -v nodejs 2>/dev/null
DEBUG (19:30:26): Command execution: command -v node 2>/dev/null
DEBUG (19:30:26): Command execution: command -v /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc 2>/dev/null
DEBUG (19:30:26): Command execution: command -v js 2>/dev/null
DEBUG (19:30:26): Command execution: command -v cscript 2>/dev/null
Compile server/coffee/app.coffee
Successfully generated server/js/app.js
Stopping process SPCRM Server
Stopped process SPCRM Server
Starting process SPCRM Server
Started process SPCRM Server
DEBUG (19:30:27): Hook :run_on_change_end executed for Guard::CoffeeScript
DEBUG (19:30:27): Guard::Process#run_on_change with ["server"]
DEBUG (19:30:27): Hook :run_on_change_begin executed for Guard::Process
Stopping process SPCRM Server
Stopped process SPCRM Server
Starting process SPCRM Server
Started process SPCRM Server
DEBUG (19:30:27): Hook :run_on_change_end executed for Guard::Process
debugger listening on port 5858
我对Ruby的了解是有限的,所以当我阅读常见问题解答,例子,维基,rubydocs时,我仍然没有更聪明。似乎在第一场比赛之后规则级联然后再次应用。
我的期望是:
任何人都可以帮助我解决这个小麻烦或启发我如何处理我的Guardfile / FS事件?
这是在Mac OX Lion上使用新的Ruby 1.9(通过Homebrew安装),最新的Guard和插件,包括fs事件gem。