Watch.json not triggering restart

Running into a weird problem with my Rantstack app not seeming to obey the watch.json.

If I make changes to the rantstack.scm file it does reload the Show tab as if it’s done something, but it doesn’t actually re-run the start command from glitch.json so nothing changes.

Is there something I’m missing? I am not great with regex syntax so maybe I’ve just got something wrong there?

Due to the nature of the platform, they enabled some limits, try increasing the throttle. I have mine set for every 15 mins. If you want to restart otherwise you can always do a quick refresh in the console.

Example:

{
  "install": {
"include": [
  "^package\\.json$",
  "^\\.env$"
]
  },
  "restart": {
"exclude": [
  "^public/",
  "^dist/"
],
"include": [
  "\\.js$",
  "\\.json"
]
  },
  "throttle": 900000
}

Just a quick edit to add a few other suggestions. You need a package.Json file (I don’t think I can see it) for best results for apps. You can start stuff from your package file, so each time you refresh the server it runs appropriately.

package.json should only be necessary for npm/javascript projects. See for instance the Python examples, which don’t use it.

Your best option would be to modify the watch.json file by just adding a random character and removing it. I use that method when working with my apps.

Probably so, you may not need it, but if you are just wanting to run something on server start you can use that as a work around, your watch.json is set to refresh every 1 second, which is not necessarily impossible but, glitch is blocking that for a good reason. Try increasing the time.

Be that as it may, the fact is, other projects, including others I have set up myself, work fine without a package.json, and NPM/Node aren’t even installed on non-Node projects like this one, so a package.json would accomplish nothing as there’s nothing to run them.

The throttle value makes no difference here either. With any value I try, the refresh event still appears to be triggered when changes are made, it just doesn’t do anything but reload my preview tab.

Pointing out that I can manually restart it is rather pointing to the problem: I don’t want to have to do that. That’s what the automatic refresh is supposed to be for.

You could have your code run the refresh command in the console. For example you can get a Node project to run the refresh command/program at a certain interval with child_process

I’m far from a racket expert (I’m probably pretty far from a racket n00b, to be honest), but I think this is related to the way racket closes over the compiled template code. The fact that the page reloads when you change the file points to the fact that the watch.json restart trigger is occurring.

https://docs.racket-lang.org/web-server/faq.html#(part._update-servlets might provide a little more context, and possibly a workaround.

I had a look at a couple workarounds to see if that might be the precompilation getting re-used. Even set up raco exe and tried just compiling to an executable and running that instead of running the original source from the interpreter. This should get around the cached compiled files, but no dice.

Something though I noticed is that there’s no new messages in the logs when I change the file. There should be another entry of the server startup text if the server is actually being closed and re-run, but it isn’t. I do see new logs though if I change the glitch.json script.

Wondering again if I’ve just got something wrong in my watch.json configuration, because actually it looks like none of the file changes except glitch.json are doing anything.

Ha! I got it!

I just moved the entire watch.json config under a "watch" key in glitch.json instead, and now everything works!