Project/Container Always Restarting (even with watch.json)

My project is always restarting around every 10 seconds, and I have watch.json file configured so that my project should restart around every minute or so, instead of every 10 seconds. Is there any way to fix this?

Note that the installReqsAndStart.sh file is what is set to start my project.
Also, if it’s of any help, my project is Python based (as you can see based on the photo), instead of Glitch’s normal Node.js and JavaScript stuff.

i believe that if you are using a python project, you should use a glitch.json file instead or watch.json for instructions to glitch

glitch.json

For non-JS projects, you can instead create a glitch.json file to tell Glitch how to setup and run your projects. This should contain the following keys:

  • "install" - this key indicates the command to run when first setting up the environment. It’s best to put here stuff that won’t change every time you change your code, like initial tool/dependency install and setup.
  • "start" - this key indicates the command to run to start the server. So this should include whatever compilation/execution steps are needed to be done every time the code changes. Note that Glitch expects that after running this command, there will be a web server waiting on an open port; if there’s not it will just keep restarting until it does.
  • "watch" - this key contains the file watcher configuration that tells Glitch on which file changes to reinstall/restart the server. This is technically optional, but without it, Glitch will only automatically restart if you change glitch.json file itself.

The "watch" key itself has three potential keys in it. "install" and "start" describe the files to watch and trigger a rerun of the commands in those keys above. Each should each contain an object with "include" and "exclude" keys, which contain arrays of strings, each string being a regex pattern matching a possible filename(s). Whenever a file changes that is matched by the include key, it will rerun the appropriate command (start or install), unless the file also matches one of the patterns in exclude .

The third, optional, key in "watch" is "throttle" , which contain the maximum frequency within which Glitch should restart after changes, given in milliseconds.

For an example of what all this looks like, here’s the glitch.json from Rantstack:

{
  "install": "sh ./install.sh",
  "start": "racket/bin/racket rantstack.scm",
  "watch": {
    "install": {
      "include": [
        "^glitch\\.json$",
        "^install\\.sh$",
        "^\\.env$"
      ]
    },
    "restart": {
      "exclude": [
        "^racket/"
      ],
      "include": [
        "\\.rkt$",
        "\\.scm$"
      ]
    },
    "throttle": 1000
  }
}
2 Likes