Skip to content
← Back to Community
Nodejs exit after time and files are getting reset
Profile icon
eliyah

i have a nodejs repl that handles my chat program when i quit nodejs normally it saves the data to the file something like [DATA,DATA,DATA] but when the repl has run for a long time its quit (which i hope it dont do) and then it saves like only [] to the file i want the repl to stay awake longer and too SAVE THE FILES.

Here is the repl https://repl.it/@eliyah/chatti-Backup-Server and why it says backup is for my server before crashed (hosted on repl.it too) and i couldn't get it to start so a made a new repl with same code and same issue with saving. Note that I have get same issues with saving on other nodejs servers

Voters
Profile icon
eliyah
Comments
hotnewtop
Profile icon
Vandesm14

You can use UptimeRobot to keep the repl up. It should keep the files saved, but I'm not quite sure why they don't save. It might be because programmatically created files aren't working in repl.it

Please mark this as answered if I helped your problem 👍

Profile icon
eliyah

@Vandesm14 thanks i can test with UptimeRobot

Profile icon
eliyah

@Vandesm14 It didn't work. because it needs to be open all time.

Profile icon
Vandesm14

@eliyah Can you send me a screenshot of the monitor you have setup?

Profile icon
eliyah

@Vandesm14
This file cannot be displayed: https://storage.googleapis.com/replit/images/1559069659823_4a4c6b3880616f181e4cc2e1a7aee9b7.pn

Profile icon
Vandesm14

@eliyah I just noticed that your repl is not an Express server, which would make it exit immediately after execution. Just copy the code from https://repl.it/languages/Express into your repl. Then it should work.
(Don't forget to change the monitor url to the repl.co link)

Profile icon
eliyah

@Vandesm14 i HAven't use express before how do i set it up?

Profile icon
Vandesm14

@eliyah It is pretty simple to setup, just copy the code from https://repl.it/languages/express and paste it into your repl. Then install the packages "express" and "body-parser". After that, you're all set!

Profile icon
Vandesm14

@Vandesm14 Did that fix it?

Please mark this as answered if I helped your problem 👍

Profile icon
eliyah
Profile icon
SLMJ

I had the same problem, so I switched to using Replit Database instead.

Profile icon
MATTHEWBECHTEL

Cool.