def main(): log("SYSTEM", "Startup in progress") log("SYSTEM", "Initializing database") Archive() log("MODULES", "Inspecting task modules") task.load_tasks() log("MODULES", "Inspecting handler modules") handler.load_handlers() log("XML", "Processing server.xml") importer.process_xml() w = World() log("WORLD", "Resolving exits") w.resolve_exits() log("WORLD", "Resolving populator objects") w.resolve_populators() log("WORLD", "Resolving placement objects") w.resolve_placements() log("NETWORK", "Initializing master socket") listener = network.ServerSocket() log("TASK", "Initializing task modules") task.init_tasks() log("SYSTEM", "Startup complete, entering main loop") while True: try: asyncore.loop(timeout=0.1, count=1) command.process_commands() task.run_tasks() except KeyboardInterrupt: print("") log("CONSOLE", "Keyboard interrupt detected") break log("SYSTEM", "Shutdown in progress") log("NETWORK", "Shutting down master socket") listener.close() log("MODULES", "Deinitializing task modules") task.deinit_tasks() log("SYSTEM", "Shutdown complete")
def stop(self): self.flush_pool() task.deinit_tasks() self.listener.close() self.listener = None