X-Git-Url: https://mudpy.org/gitweb?p=mudpy.git;a=blobdiff_plain;f=mudpy;h=c295fd4746ae52ff84d3edd528452174537a0f50;hp=5130834ea8b8e0516bb62a5daa3d025fb86c9d57;hb=e34437c01ef4ca0e2413bd08a76dd11b690c49a5;hpb=fecd4c0fc49593052697b8cf199603cf1fac2b61 diff --git a/mudpy b/mudpy index 5130834..c295fd4 100755 --- a/mudpy +++ b/mudpy @@ -1,36 +1,40 @@ #!/usr/bin/python -"""Skeletal executable for the MUFF Engine""" +# -*- coding: utf-8 -*- +u"""Skeletal executable for the mudpy engine.""" -# Copyright (c) 2005 mudpy, Jeremy Stanley , all rights reserved. -# Licensed per terms in the LICENSE file distributed with this software. +# Copyright (c) 2004-2009 Jeremy Stanley . Permission +# to use, copy, modify, and distribute this software is granted under +# terms provided in the LICENSE file distributed with this software. -# muff uses the ini-style configs supported by the ConfigParser module -import ConfigParser +# core objects for the mudpy engine +import mudpy -# need the sys module to alter the import path appropriately +# log an initial message import sys +mudpy.log(u"Started mudpy with command line: " + u" ".join(sys.argv)) -def get_main_loop(): - """Find and return the main loop function""" - - # figure out where to find our main configuration file - config_data = ConfigParser.SafeConfigParser() - config_dirs = [".", "./etc", "/usr/local/muff", "/usr/local/muff/etc", "/etc/muff", "/etc" ] - config_name = "mudpy.conf" - config_files = [] - for each_dir in config_dirs: - config_files.append(each_dir + "/" + config_name) - - # load the config file, get the module path and add it to sys.path - config_data.read(config_files) - module_path = config_data.get("files", "modules") - sys.path.append(module_path) - - # import the main loop function - from muff.muffmain import main - return main - -# load the main loop and run it -main = get_main_loop() -main() +# fork and disassociate +mudpy.daemonize() + +# make the pidfile +mudpy.create_pidfile(mudpy.universe) + +# loop indefinitely while the world is not flagged for termination or +# there are still connected users +while not mudpy.universe.terminate_flag or mudpy.universe.userlist: + + # the world was flagged for a reload of all code/data + if mudpy.universe.reload_flag: reload(mudpy) + + # do what needs to be done on each pulse + mudpy.on_pulse() + +# the loop has terminated, so save persistent data +mudpy.universe.save() + +# log a final message +mudpy.log(u"Shutting down now.") + +# get rid of the pidfile +mudpy.remove_pidfile(mudpy.universe)