Beispiel #1
0
    def at_post_portal_sync(self):
        """
        This is called just after the portal has finished syncing back data to the server
        after reconnecting.
        """
        # one of reload, reset or shutdown
        mode = self.getset_restart_mode()

        from evennia.scripts.monitorhandler import MONITOR_HANDLER
        MONITOR_HANDLER.restore(mode == 'reload')

        from evennia.scripts.tickerhandler import TICKER_HANDLER
        TICKER_HANDLER.restore(mode == 'reload')

        # after sync is complete we force-validate all scripts
        # (this also starts any that didn't yet start)
        ScriptDB.objects.validate(init_mode=mode)

        # start the task handler
        from evennia.scripts.taskhandler import TASK_HANDLER
        TASK_HANDLER.load()
        TASK_HANDLER.create_delays()

        # delete the temporary setting
        ServerConfig.objects.conf("server_restart_mode", delete=True)
Beispiel #2
0
    def at_post_portal_sync(self, mode):
        """
        This is called just after the portal has finished syncing back data to the server
        after reconnecting.

        Args:
            mode (str): One of reload, reset or shutdown.

        """

        from evennia.scripts.monitorhandler import MONITOR_HANDLER
        MONITOR_HANDLER.restore(mode == 'reload')

        from evennia.scripts.tickerhandler import TICKER_HANDLER
        TICKER_HANDLER.restore(mode == 'reload')

        # after sync is complete we force-validate all scripts
        # (this also starts any that didn't yet start)
        ScriptDB.objects.validate(init_mode=mode)

        # start the task handler
        from evennia.scripts.taskhandler import TASK_HANDLER
        TASK_HANDLER.load()
        TASK_HANDLER.create_delays()

        # delete the temporary setting
        ServerConfig.objects.conf("server_restart_mode", delete=True)
Beispiel #3
0
    def at_post_portal_sync(self, mode):
        """
        This is called just after the portal has finished syncing back data to the server
        after reconnecting.

        Args:
            mode (str): One of reload, reset or shutdown.

        """

        from evennia.scripts.monitorhandler import MONITOR_HANDLER

        MONITOR_HANDLER.restore(mode == "reload")

        from evennia.scripts.tickerhandler import TICKER_HANDLER

        TICKER_HANDLER.restore(mode == "reload")

        # after sync is complete we force-validate all scripts
        # (this also starts any that didn't yet start)
        ScriptDB.objects.validate(init_mode=mode)

        # start the task handler
        from evennia.scripts.taskhandler import TASK_HANDLER

        TASK_HANDLER.load()
        TASK_HANDLER.create_delays()

        # check so default channels exist
        from evennia.comms.models import ChannelDB
        from evennia.accounts.models import AccountDB
        from evennia.utils.create import create_channel

        god_account = AccountDB.objects.get(id=1)
        # mudinfo
        mudinfo_chan = settings.CHANNEL_MUDINFO
        if not mudinfo_chan:
            raise RuntimeError("settings.CHANNEL_MUDINFO must be defined.")
        if not ChannelDB.objects.filter(db_key=mudinfo_chan["key"]):
            channel = create_channel(**mudinfo_chan)
            channel.connect(god_account)
        # connectinfo
        connectinfo_chan = settings.CHANNEL_MUDINFO
        if connectinfo_chan:
            if not ChannelDB.objects.filter(db_key=mudinfo_chan["key"]):
                channel = create_channel(**connectinfo_chan)
        # default channels
        for chan_info in settings.DEFAULT_CHANNELS:
            if not ChannelDB.objects.filter(db_key=chan_info["key"]):
                channel = create_channel(**chan_info)
                channel.connect(god_account)

        # delete the temporary setting
        ServerConfig.objects.conf("server_restart_mode", delete=True)
Beispiel #4
0
 def test_server_restart(self):
     # emulate a server restart
     timedelay = self.timedelay
     utils.delay(timedelay, dummy_func, self.char1.dbref, persistent=True)
     _TASK_HANDLER.clear(False)  # remove all tasks from task handler, do not save this change.
     _TASK_HANDLER.clock.advance(timedelay)  # advance twisted reactor time past callback time
     self.assertEqual(self.char1.ndb.dummy_var, False)  # task has not run
     _TASK_HANDLER.load()  # load persistent tasks from database.
     _TASK_HANDLER.create_delays()  # create new deffered instances from persistent tasks
     _TASK_HANDLER.clock.advance(timedelay)  # Clock must advance to trigger, even if past timedelay
     self.assertEqual(self.char1.ndb.dummy_var, 'dummy_func ran')