Imported from archive.
[mudpy.git] / mudpy
diff --git a/mudpy b/mudpy
index 5130834..c295fd4 100755 (executable)
--- 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 <fungi@yuggoth.org>, all rights reserved.
-# Licensed per terms in the LICENSE file distributed with this software.
+# Copyright (c) 2004-2009 Jeremy Stanley <fungi@yuggoth.org>. 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)