spring icon indicating copy to clipboard operation
spring copied to clipboard

Support configuring files/directories to be ignored by the watcher

Open arr-dev opened this issue 12 years ago • 9 comments

Is there a way to setup custom list of files/directories to be ignored by watcher?

We are using custom script for starting rails console which runs svn update before each start, which causes spring to restart environment, since .svn folders are changed on each update.

Thanks in advance.

arr-dev avatar Mar 29 '13 11:03 arr-dev

I do not believe that an explicit Spring.ignore method exists, although it looks like Spring::Watcher should only mark the application instance stale if one of the loaded files has changed. It should not be restarting every time any file changes within your project root.

Are you using the Spring::Watcher::Listen or the standard Spring::Watcher::Polling?

rwjblue avatar Mar 29 '13 17:03 rwjblue

I am not sure, but since listen gem is in Gemfile, I'm guessing it uses Spring::Watcher::Listen.

I thought it works on only loaded files, but it restarts every time I do svn update, but not without it. And I've checked after update and only .svn directories are modified.

arr-dev avatar Mar 29 '13 19:03 arr-dev

I wrote a quick test (see gist) that confirms with both Spring::Watcher::Listen and Spring::Watcher::Polling that the application is not marked 'stale' when unwatched files are added to a watched directory.

If the svn up is causing loaded files to change, that would cause Spring to reload. Is that a possibility in this case (possibly check svn status --show-updates or similar)?

If nothing is changing then we need to figure out the circumstances so that we can replicate the issue.

rwjblue avatar Mar 29 '13 19:03 rwjblue

Yes, your test passes.

Problem is that svn up, in most cases, doesn't do anything to the loaded files. Most of the time, there are no changes, so it only updates mtime on its internal files, in .svn directories and root directory, as far as I can see, inspecting with find . -mmin -1.

But after each svn up, Spring is restarted. List of changed files/directories after svn up is bellow.

.
./script/.svn
./config/environments/.svn
./config/locales/defaults/.svn
./config/locales/.svn
./config/initializers/.svn
./config/.svn
./spec/factories/.svn
./spec/requests/.svn
./spec/support/requests/.svn
./spec/support/models/.svn
./spec/support/.svn
./spec/models/.svn
./spec/.svn
./db/migrate/.svn
./db/.svn
./public/.svn
./log/.svn
./lib/.svn
./lib/assets/.svn
./lib/tasks/.svn
./tmp/cache/.svn
./tmp/cache/assets/.svn
./tmp/.svn
./doc/.svn
./.svn
./.svn/entries
./.svn/tmp
./app/mailers/.svn
./app/serializers/.svn
./app/controllers/.svn
./app/models/.svn
./app/.svn
./app/assets/stylesheets/.svn
./app/assets/javascripts/.svn
./app/assets/.svn
./app/assets/images/.svn
./app/helpers/.svn
./app/views/layouts/.svn
./app/views/oauth_clients/.svn
./app/views/oauth/.svn
./app/views/.svn
./vendor/plugins/.svn
./vendor/.svn
./vendor/assets/stylesheets/.svn
./vendor/assets/javascripts/.svn
./vendor/assets/.svn

arr-dev avatar Mar 29 '13 20:03 arr-dev

Not being lazy (surprisingly :) ) I've manually touched every one of these folders, followed by spring rails console.

It didn't restart.

But after svn up, without any updates from the server, it restarted.

arr-dev avatar Mar 29 '13 20:03 arr-dev

Ok, so I think we are specifically listening to a any change (not just loaded files) in certain directories (like 'config/initializers'. Since svn is changing files in these directories spring gets restarted.

I will try to add ignore method to either 'Spring.ignore' (to correspond with 'Spring.watch') or 'Spring::Watcher::Abstract' & co.

@jonleighton - Do you have a preference?

Sent from my iPhone

On Mar 29, 2013, at 4:29 PM, soul-rebel [email protected] wrote:

Yes, your test passes.

Problem is that svn up, in most cases, doesn't do anything to the loaded files. Most of the time, there are no changes, so it only updates mtime on its internal files, in .svn directories and root directory, as far as I can see, inspecting with find . -mmin -1.

But after each svn up, Spring is restarted. List of changed files/directories after svn up is bellow.

. ./script/.svn ./config/environments/.svn ./config/locales/defaults/.svn ./config/locales/.svn ./config/initializers/.svn ./config/.svn ./spec/factories/.svn ./spec/requests/.svn ./spec/support/requests/.svn ./spec/support/models/.svn ./spec/support/.svn ./spec/models/.svn ./spec/.svn ./db/migrate/.svn ./db/.svn ./public/.svn ./log/.svn ./lib/.svn ./lib/assets/.svn ./lib/tasks/.svn ./tmp/cache/.svn ./tmp/cache/assets/.svn ./tmp/.svn ./doc/.svn ./.svn ./.svn/entries ./.svn/tmp ./app/mailers/.svn ./app/serializers/.svn ./app/controllers/.svn ./app/models/.svn ./app/.svn ./app/assets/stylesheets/.svn ./app/assets/javascripts/.svn ./app/assets/.svn ./app/assets/images/.svn ./app/helpers/.svn ./app/views/layouts/.svn ./app/views/oauth_clients/.svn ./app/views/oauth/.svn ./app/views/.svn ./vendor/plugins/.svn ./vendor/.svn ./vendor/assets/stylesheets/.svn ./vendor/assets/javascripts/.svn ./vendor/assets/.svn — Reply to this email directly or view it on GitHub.

rwjblue avatar Mar 29 '13 21:03 rwjblue

I believe that I have managed to debug the problem.

@rjackson You are right, it seems that it gets reloaded because config/initializers/.svn/lock file is created. That file is deleted when svn up is finished, but it marks stale during the update.

arr-dev avatar Mar 29 '13 22:03 arr-dev

In that case the watcher is appropriately marking the application instance as stale (because a file in a directory we explicitly told it to watch was added).

We just need a way to prevent it in certain circumstances. I'll work on a pull request adding some sort of ignore functionality.

Sent from my iPhone

On Mar 29, 2013, at 6:19 PM, soul-rebel [email protected] wrote:

I believe that I have managed to debug the problem.

@rjackson You are right, it seems that it gets reloaded because config/initializers/.svn/lock file is created. That file is deleted when svn up is finished, but it marks stale during the update.

— Reply to this email directly or view it on GitHub.

rwjblue avatar Mar 29 '13 22:03 rwjblue

Any updates on this?

fidalgo avatar Mar 23 '21 10:03 fidalgo