mirror of
https://github.com/evennia/evennia.git
synced 2026-03-27 18:26:32 +01:00
Prevent server from reconnecting to Portal mid-shutdown
This commit is contained in:
parent
09d0c99a21
commit
e944a6f16f
3 changed files with 23 additions and 11 deletions
|
|
@ -5,7 +5,7 @@ Portal. This module sets up the Client-side communication.
|
|||
"""
|
||||
|
||||
from evennia.server.portal import amp
|
||||
from twisted.internet import protocol
|
||||
from twisted.internet import protocol, reactor
|
||||
from evennia.utils import logger
|
||||
|
||||
|
||||
|
|
@ -84,8 +84,9 @@ class AMPClientFactory(protocol.ReconnectingClientFactory):
|
|||
reason (str): Eventual text describing why connection failed.
|
||||
|
||||
"""
|
||||
logger.log_info("Attempting to reconnect to Portal ...")
|
||||
protocol.ReconnectingClientFactory.clientConnectionFailed(self, connector, reason)
|
||||
if reactor.running:
|
||||
logger.log_info("Attempting to reconnect to Portal ...")
|
||||
protocol.ReconnectingClientFactory.clientConnectionFailed(self, connector, reason)
|
||||
|
||||
|
||||
class AMPServerClientProtocol(amp.AMPMultiConnectionProtocol):
|
||||
|
|
|
|||
|
|
@ -1363,7 +1363,7 @@ def del_pid(pidfile):
|
|||
os.remove(pidfile)
|
||||
|
||||
|
||||
def kill(pidfile, component='Server', killsignal=SIG):
|
||||
def kill(pidfile, component='Server', callback=None, errback=None, killsignal=SIG):
|
||||
"""
|
||||
Send a kill signal to a process based on PID. A customized
|
||||
success/error message will be returned. If clean=True, the system
|
||||
|
|
@ -1372,6 +1372,8 @@ def kill(pidfile, component='Server', killsignal=SIG):
|
|||
Args:
|
||||
pidfile (str): The path of the pidfile to get the PID from.
|
||||
component (str, optional): Usually one of 'Server' or 'Portal'.
|
||||
errback (callable, optional): Called if signal failed to send.
|
||||
callback (callable, optional): Called if kill signal was sent successfully.
|
||||
killsignal (int, optional): Signal identifier for signal to send.
|
||||
|
||||
"""
|
||||
|
|
@ -1402,10 +1404,16 @@ def kill(pidfile, component='Server', killsignal=SIG):
|
|||
"Try removing it manually.".format(
|
||||
component=component, pid=pid, pidfile=pidfile))
|
||||
return
|
||||
print("Sent kill signal to {component}.".format(component=component))
|
||||
return
|
||||
print("Could not send kill signal - {component} does "
|
||||
"not appear to be running.".format(component=component))
|
||||
if callback:
|
||||
callback()
|
||||
else:
|
||||
print("Sent kill signal to {component}.".format(component=component))
|
||||
return
|
||||
if errback:
|
||||
errback()
|
||||
else:
|
||||
print("Could not send kill signal - {component} does "
|
||||
"not appear to be running.".format(component=component))
|
||||
|
||||
|
||||
def show_version_info(about=False):
|
||||
|
|
@ -1715,8 +1723,10 @@ def run_menu():
|
|||
elif inp == 7:
|
||||
kill(SERVER_PIDFILE, 'Server')
|
||||
elif inp == 8:
|
||||
kill(PORTAL_PIDFILE, 'Portal')
|
||||
global REACTOR_RUN
|
||||
kill(SERVER_PIDFILE, 'Server')
|
||||
reactor.callLater(5, kill, PORTAL_PIDFILE, 'Portal')
|
||||
REACTOR_RUN = True
|
||||
elif inp == 9:
|
||||
if not SERVER_LOGFILE:
|
||||
init_game_directory(CURRENT_DIR, check_db=False)
|
||||
|
|
@ -1878,7 +1888,7 @@ def main():
|
|||
elif option == 'sstop':
|
||||
stop_server_only()
|
||||
elif option == 'kill':
|
||||
kill(PORTAL_PIDFILE, 'Portal')
|
||||
kill(SERVER_PIDFILE, 'Server')
|
||||
kill(SERVER_PIDFILE, 'Server')
|
||||
elif option == 'skill':
|
||||
kill(SERVER_PIDFILE, 'Server')
|
||||
|
|
|
|||
|
|
@ -210,7 +210,8 @@ class Evennia(object):
|
|||
Optimize some SQLite stuff at startup since we
|
||||
can't save it to the database.
|
||||
"""
|
||||
if ((".".join(str(i) for i in django.VERSION) < "1.2" and settings.DATABASES.get('default', {}).get('ENGINE') == "sqlite3") or
|
||||
if ((".".join(str(i) for i in django.VERSION) < "1.2" and
|
||||
settings.DATABASES.get('default', {}).get('ENGINE') == "sqlite3") or
|
||||
(hasattr(settings, 'DATABASES') and
|
||||
settings.DATABASES.get("default", {}).get('ENGINE', None) ==
|
||||
'django.db.backends.sqlite3')):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue