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:
parent
f7b5c1d012
commit
5d0ff1386a
@ -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()
|
Loading…
Reference in New Issue
Block a user