Closed kavithabhaskaran closed 9 years ago
Could you give maybe create an example of this, with a folder layout? I'm a little lost by what you mean by "in such a way that any requests that I send to 'Abc' should be redirected to 'Def'" sorry :(
So if I have a dir "mock" which has a hierarchy and has the corresponding index.get.json files in it. $ln -s ./mock mockA (sym link creation) this works when the Canned API server starts but when this sym link gets switched to another folder say "mockB", then Canned still uses the old data from "mockA".
So it still probably has a reference to the data in mockA.
Is there a way this kind of a situation is/could be handled?
Ok so here is what I did:
$ mkdir dir1 dir2
$ echo '{"dir1":1}' > dir1/index.get.json
$ echo '{"dir2":2}' > dir2/index.get.json
$ canned ./
in a different shell
$ ln -s dir1 foo
$ curl localhost:3000/foo # => {"dir1":1}
$ rm foo
$ ln -s dir2 foo
$ curl localhost:3000/foo # => {"dir2":2}
Did I understand the scenario right? I'm not really sure about this...
This seems to work fine as far as I can tell, I'm on MacOS 10.9.5. There is no caching happening inside canned as far as I can see. On which OS / Version are you? Maybe there is some filesystem caching going on?
It works the first time you create a symlink but the 2nd time you change the created sym link to point to some other folder, it did not seem to work.
So I need to change the symlink in my scenario one more time right? Will try when I'm back at my computer, thanks.
Yes, please. Thank you @sideshowcoder !
Ok so I updated what I did:
$ mkdir dir1 dir2
$ echo '{"dir1":1}' > dir1/index.get.json
$ echo '{"dir2":2}' > dir2/index.get.json
$ canned ./
in a different shell
$ ln -s dir1 foo
$ curl localhost:3000/foo # => {"dir1":1}
$ rm foo
$ ln -s dir2 foo
$ curl localhost:3000/foo # => {"dir2":2}
$ rm foo
$ ln -s dir1 foo
$ curl localhost:3000/foo # => {"dir1":1}
Basically doing the same as before but switching the directories 1 more time, actually about 5 more times to be sure but no change.
This seems to be related to specific OS versions or something like this. In case you can give me any hints on what you run maybe others can help out, I'm a little out of ideas here.
I'm closing this since it seems unrelated to to canned internal stuff.
So when I have the Canned API server running and I make changes to a an "index.get.json" file, I do not have to restart my server (verified that and it works fine). I can continue sending requests and get responses (including the updated data from index.get.json). My question is if I have all the data in a folder called "Abc" and I sym link it "Def" in such a way that any requests that I send to "Abc" should be re-directed to "Def", that does not seem to work unless I re-start the canned API server. How is that handled/supposed to be handled in the source code?