Skip to content
Sign upLog in
← Back to Community

restart on error

Profile icon
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
Profile icon
SanveedFaisal
Profile icon
Highwayman
Profile icon
ragnork
Profile icon
IvanChang111
Comments
hotnewtop
Profile icon
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...?

Profile icon
LukeC1

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

@Highwayman

Profile icon
Highwayman

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

@LukeC1

Profile icon
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?

Profile icon
vitasehnalek

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

Profile icon
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

Profile icon
IvanChang111

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