Ask coding questions

← Back to all posts
restart on error
ragnork

My repl is a discord bot the fetches from an api, and i would prefer not to have to restart it every time someone makes a spelling mistake, so is there a way to have my repl restart on an error

Voters
SanveedFaisal
Highwayman
ragnork
IvanChang111
Comments
hotnewtop
Highwayman

maybe what you want to do is go into your .replit file and change run="npm start" to
run="while true do npm start done", which will just automatically run your program again every time it shuts down over and over forever...?

LukeC1

i tried changing run to "while true; do npm start; sleep 2; done" and it seems to be working @Highwayman

Highwayman

ah yes, semicolons heh I forgot those XP thanks yeah makes sense. @LukeC1

Highwayman

What exactly do you mean by restart on error? do you mean like if your entire program crashes, you want the repl to automatically restart?

vitasehnalek

@Highwayman I guess, this can be what is he thinking of.

Highwayman

Yeah, but looking at it again, it looks more like the api throws an exception or something, which is way easier to recover from. @vitasehnalek

IvanChang111

I have the same problem, except when I restart is still has an error:(