Imported from archive.
[mudpy.git] / mudpy
diff --git a/mudpy b/mudpy
index 6b6c1c3..8e115bd 100755 (executable)
--- a/mudpy
+++ b/mudpy
@@ -1,28 +1,45 @@
 #!/usr/bin/python
 """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-2008 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.
 
 # core objects for the mudpy engine
 import mudpy
-from mudpy import log, on_pulse, reload_data, universe
+
+# a consistent list so we can reimport these on reload
+importlist = [
+       "argv",
+       "create_pidfile",
+       "daemonize",
+       "log",
+       "on_pulse",
+       "reload_data",
+       "remove_pidfile",
+       "universe"
+       ]
+for item in importlist: exec("from mudpy import " + item)
+
+# log an initial message
+log("Started mudpy with command line: " + " ".join(argv))
+
+# fork and disassociate
+daemonize()
+
+# make the pidfile
+create_pidfile(universe)
 
 # loop indefinitely while the world is not flagged for termination or
 # there are connected users
-while not universe.terminate_world or universe.userlist:
+while not universe.terminate_flag or universe.userlist:
 
        # the world was flagged for a reload of all code/data
-       if universe.reload_modules:
+       if universe.reload_flag:
 
                # reload the mudpy module
                reload(mudpy)
-
-               # move data into new persistent objects
-               reload_data()
-
-               # reset the reload flag
-               universe.reload_modules = False
+               for item in importlist: exec("from mudpy import " + item)
 
        # do what needs to be done on each pulse
        on_pulse()
@@ -33,3 +50,6 @@ universe.save()
 # log a final message
 log("Shutting down now.")
 
+# get rid of the pidfile
+remove_pidfile(universe)
+