newsproutsmedia / chat

Chat site using socket.io
https://chatapp.newsproutsmedia.com
0 stars 0 forks source link

(bug) Manage NodeJs crash #141

Closed newsproutsmedia closed 3 years ago

newsproutsmedia commented 3 years ago

Since data is not intended to be permanently persisted, all transient socket data is lost when NodeJS crashes. This means that users, rooms, and message history are lost for all existing sockets -- this will, because of the nature of the program, lead to problems and additional crashes upon reboot of the system and reconnection with the sockets.

Temporary fix: 1) Disconnect and logout all sockets prior to the crash with a message indicating the problem.

Possible long-term solutions: 1) Temporarily persist data prior to NodeJs crashing. This solution could utilize the "process.exit" event to store the data in a file on the server. Upon startup, the program could check to see if that file exists. If it exists, the system would restore the arrays and then wipe the file clean. 2) Persist data in a datastore for the length of the chat session and wipe it afterwards.

https://stackoverflow.com/questions/26328348/node-js-server-crash-handling