1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2025-01-09 00:20:08 +00:00

Cleanup before shutdown

This commit is contained in:
Tim Düsterhus 2012-10-14 17:58:13 +02:00
parent f7b5c1d012
commit 5d0ff1386a

View File

@ -30,6 +30,11 @@ class Server
@initUnixSocket() @initUnixSocket()
@initSocketIO() @initSocketIO()
process.on 'exit', @shutdown.bind @
process.on 'uncaughtException', @shutdown.bind @
process.on 'SIGINT', @shutdown.bind @
process.on 'SIGTERM', @shutdown.bind @
setInterval (() -> setInterval (() ->
@socket.sockets.emit 'newMessage' @socket.sockets.emit 'newMessage'
).bind(@), 60e3 ).bind(@), 60e3
@ -58,5 +63,11 @@ class Server
socket.listen process.cwd() + '/../data.sock' socket.listen process.cwd() + '/../data.sock'
fs.chmod process.cwd() + '/../data.sock', '777' fs.chmod process.cwd() + '/../data.sock', '777'
shutdown: () ->
return unless fs.existsSync process.cwd() + '/../data.sock'
log 'Shutting down'
fs.unlinkSync process.cwd() + '/../data.sock'
process.exit()
new Server() new Server()