Fix server exit while there are active sessions

This commit is contained in:
Florian Mounier
2015-10-06 17:01:28 +02:00
parent 140b0902fc
commit ced1148275
2 changed files with 8 additions and 5 deletions

View File

@@ -14,7 +14,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
__version__ = '2.0.2'
__version__ = '2.0.3'
import os

View File

@@ -219,6 +219,9 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
@classmethod
def close_all(cls, session, user):
terminals = TermWebSocket.terminals.get(user.name)
del terminals[session]
sessions = TermWebSocket.sessions.get(user.name)
if sessions:
sockets = sessions[session]
@@ -227,9 +230,6 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
socket.close()
del sessions[session]
terminals = TermWebSocket.terminals.get(user.name)
del terminals[session]
@classmethod
def broadcast(cls, session, message, user):
cls.history[session] += message
@@ -277,7 +277,10 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
else:
self.log.error(
'Socket with neither session nor terminal %r' % self)
if self.application.systemd and not len(TermWebSocket.sockets):
if (self.application.systemd and
not len(TermWebSocket.sockets) and
not sum([len(sessions)
for user, sessions in TermWebSocket.terminals.items()])):
sys.exit(0)