Ask coding questions

← Back to all posts
How to completely restart the code
[deleted]

So all I want to do is restart the code completely, with code. I am using javascript. So like I want to run a file, that every so often, it restarts the whole project, like you are pushing stop and start again. Any help?

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
Arshveer
Comments
hotnewtop
Coder100

Sure, try something like this:
Create a .replit file:

Create a main.sh file:

and to restart your code,

now, because it keeps running node . FOREVER, after exiting the program, it will run it again.

[deleted]

@Coder100 Thanks so much!

Coder100

no problem! Mark as correct answer? @JohnS4

[deleted]

@Coder100 I am not sure yet, but so far it is working perfectly! I will probably have to wait for a bit longer

Coder100

yay!! Awesome! Glad to help :) @JohnS4

[deleted]

@Coder100 So is there a way to have it restart on intervals? like every 5 minutes the code restarts?

Coder100

sure,

@JohnS4

[deleted]

@Coder100 ok, ill see if it works.

[deleted]

I did that, and it shuts it down, but it does not restart. How can I make it restart? @Coder100

Coder100

hmm it didn't restart? ill try it out @JohnS4

Coder100
Coder100

works for me @JohnS4

[deleted]

it still dosent work. I have no idea [email protected]

[deleted]

yours worked, but mine did [email protected]

[deleted]

@Coder100 this is what i get

Coder100

send repl? @JohnS4

[deleted]

this is a discord bot, so ignore the token, I am gonna get a new one [email protected]

https://repl.it/join/kewwdmkk-johns4

CodingCactus

well you could put the whole code in a while loop or something?