Hello, I want to make my bot never restart by its self, I want to be the only to restart it. Is there anyway at all? Like changing the interval number in watch.json or anything else?
Thanks, murf.
Hello, I want to make my bot never restart by its self, I want to be the only to restart it. Is there anyway at all? Like changing the interval number in watch.json or anything else?
Thanks, murf.
Hey MurfCode,
Totally. By default, the Glitch will restart if anything is changed. You can override that in watch.json by specifying include and exclude files/folders.
We do this for glitch.com itself, take a look at https://glitch.com/edit/#!/community?path=watch.json:1:0 for an example configuration.
In this example, we do a big full restart (including pnpm install) only if package.json or .env change, we deliberately donât restart if anything inside the âsrcâ folder changes, and then we have couple other special cases.
For the stuff that Glitch isnât restarting for us, to notice the changes we run our own watcher in the âprestartâ step in package.json, and that lets us monitor those other files and rebuild them as assets to be served without interruption from the main server endpoint.
Note that âneverâ is a tall order; projects will go down for maintenance or go to sleep, etc., but you can override the behavior of ârestart whenever I change itâ and that will let you limit your restarts to âpretty much never.â
Question @jude, If we do this, what is the option to start it? Is there any specific button, or do we have to visit the website, or� Thank you
I edit the watch.json and just set it back very fast to restart mine.
Hi LeoDog896,
Yup, MurfCode has a good way about it.
For a little more detail:
The key controls are in your package.json file â the âstartâ hook and the (not included by default) âprestartâ hook. These are the invocations into your code that Glitch knows to run, and watch.json is what controls when those items get invoked. If you change watch.json from its defaults, then itâs now up to you to decide what you want the behavior to be.
Personally I try to model the âcontinuous deploymentâ philosophy: You want something thatâll watch for changes and build an artifact, youâll want something that watches for new artifacts and tests them, and youâll want something that watches for new tested-artifacts and restarts the app to host them.
A Glitchy way to do this is to have your âprestartâ hook in package.json invoke your code that watches your file changes, tests, and publishes your artifact, and your âstartâ hook run the code that hosts your server and runs the artifact.
But this starts to get tricky, and it sure is nice to keep things simple where we can, so I wouldnât go this far unless you really canât make things work with the default config and tips like what MurfCode has for ya