Restart server, run collectstatic at init.

Fix tintin++ default. Resolves #1593.
This commit is contained in:
Griatch 2018-08-18 10:38:06 +02:00
parent 1aaee33138
commit 2a6e914161
5 changed files with 23 additions and 12 deletions

View file

@ -51,7 +51,7 @@ class AMPClientFactory(protocol.ReconnectingClientFactory):
def buildProtocol(self, addr): def buildProtocol(self, addr):
""" """
Creates an AMPProtocol instance when connecting to the server. Creates an AMPProtocol instance when connecting to the AMP server.
Args: Args:
addr (str): Connection address. Not used. addr (str): Connection address. Not used.
@ -108,6 +108,8 @@ class AMPServerClientProtocol(amp.AMPMultiConnectionProtocol):
# back with the Server side. We also need the startup mode (reload, reset, shutdown) # back with the Server side. We also need the startup mode (reload, reset, shutdown)
self.send_AdminServer2Portal( self.send_AdminServer2Portal(
amp.DUMMYSESSION, operation=amp.PSYNC, spid=os.getpid(), info_dict=info_dict) amp.DUMMYSESSION, operation=amp.PSYNC, spid=os.getpid(), info_dict=info_dict)
# run the intial setup if needed
self.factory.server.run_initial_setup()
def data_to_portal(self, command, sessid, **kwargs): def data_to_portal(self, command, sessid, **kwargs):
""" """

View file

@ -59,7 +59,7 @@ def create_objects():
""" """
logger.log_info("Creating objects (Account #1 and Limbo room) ...") logger.log_info("Initial setup: Creating objects (Account #1 and Limbo room) ...")
# Set the initial User's account object's username on the #1 object. # Set the initial User's account object's username on the #1 object.
# This object is pure django and only holds name, email and password. # This object is pure django and only holds name, email and password.
@ -121,7 +121,7 @@ def create_channels():
Creates some sensible default channels. Creates some sensible default channels.
""" """
logger.log_info("Creating default channels ...") logger.log_info("Initial setup: Creating default channels ...")
goduser = get_god_account() goduser = get_god_account()
for channeldict in settings.DEFAULT_CHANNELS: for channeldict in settings.DEFAULT_CHANNELS:
@ -144,11 +144,21 @@ def at_initial_setup():
mod = __import__(modname, fromlist=[None]) mod = __import__(modname, fromlist=[None])
except (ImportError, ValueError): except (ImportError, ValueError):
return return
logger.log_info(" Running at_initial_setup() hook.") logger.log_info("Initial setup: Running at_initial_setup() hook.")
if mod.__dict__.get("at_initial_setup", None): if mod.__dict__.get("at_initial_setup", None):
mod.at_initial_setup() mod.at_initial_setup()
def collectstatic():
"""
Run collectstatic to make sure all web assets are loaded.
"""
from django.core.management import call_command
logger.log_info("Initial setup: Gathering static resources using 'collectstatic'")
call_command('collectstatic', '--noinput')
def reset_server(): def reset_server():
""" """
We end the initialization by resetting the server. This makes sure We end the initialization by resetting the server. This makes sure
@ -159,8 +169,8 @@ def reset_server():
""" """
ServerConfig.objects.conf("server_epoch", time.time()) ServerConfig.objects.conf("server_epoch", time.time())
from evennia.server.sessionhandler import SESSIONS from evennia.server.sessionhandler import SESSIONS
logger.log_info(" Initial setup complete. Restarting Server once.") logger.log_info("Initial setup complete. Restarting Server once.")
SESSIONS.server.shutdown(mode='reset') SESSIONS.portal_reset_server()
def handle_setup(last_step): def handle_setup(last_step):
@ -186,6 +196,7 @@ def handle_setup(last_step):
setup_queue = [create_objects, setup_queue = [create_objects,
create_channels, create_channels,
at_initial_setup, at_initial_setup,
collectstatic,
reset_server] reset_server]
# step through queue, from last completed function # step through queue, from last completed function

View file

@ -116,7 +116,7 @@ class Ttype(object):
self.protocol.protocol_flags["FORCEDENDLINE"] = False self.protocol.protocol_flags["FORCEDENDLINE"] = False
if cupper.startswith("TINTIN++"): if cupper.startswith("TINTIN++"):
self.protocol.protocol_flags["FORCEDENDLINE"] = False self.protocol.protocol_flags["FORCEDENDLINE"] = True
if (cupper.startswith("XTERM") or if (cupper.startswith("XTERM") or
cupper.endswith("-256COLOR") or cupper.endswith("-256COLOR") or

View file

@ -181,9 +181,6 @@ class Evennia(object):
self.start_time = time.time() self.start_time = time.time()
# Run the initial setup if needed
self.run_initial_setup()
# initialize channelhandler # initialize channelhandler
channelhandler.CHANNELHANDLER.update() channelhandler.CHANNELHANDLER.update()
@ -274,6 +271,8 @@ class Evennia(object):
def run_initial_setup(self): def run_initial_setup(self):
""" """
This is triggered by the amp protocol when the connection
to the portal has been established.
This attempts to run the initial_setup script of the server. This attempts to run the initial_setup script of the server.
It returns if this is not the first time the server starts. It returns if this is not the first time the server starts.
Once finished the last_initial_setup_step is set to -1. Once finished the last_initial_setup_step is set to -1.

View file

@ -278,7 +278,7 @@ class ServerSessionHandler(SessionHandler):
""" """
super(ServerSessionHandler, self).__init__(*args, **kwargs) super(ServerSessionHandler, self).__init__(*args, **kwargs)
self.server = None self.server = None # set at server initialization
self.server_data = {"servername": _SERVERNAME} self.server_data = {"servername": _SERVERNAME}
def _run_cmd_login(self, session): def _run_cmd_login(self, session):
@ -290,7 +290,6 @@ class ServerSessionHandler(SessionHandler):
if not session.logged_in: if not session.logged_in:
self.data_in(session, text=[[CMD_LOGINSTART], {}]) self.data_in(session, text=[[CMD_LOGINSTART], {}])
def portal_connect(self, portalsessiondata): def portal_connect(self, portalsessiondata):
""" """
Called by Portal when a new session has connected. Called by Portal when a new session has connected.