How does touch tmp/restart.txt actually work?

Viewed 1348

I see people here saying to touch tmp/restart.txt to restart a rails sever, but I am interested to know how this actually works. restart.txt is an empty file in the tmp folder, so how does Rails know to restart the server when you touch the file? I.e. where is the code that allows this feature to work, since it's not in restart.txt?

1 Answers

If you take a look at config/spring.rb you'll see that Spring is configured to watch this file. I believe the default is to poll every 2 seconds.

Spring.watch(
  "tmp/restart.txt",
  "tmp/caching-dev.txt"
)
Related