#!/usr/bin/python
-"""Skeletal executable for the mudpy 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.
# core objects for the mudpy engine
import mudpy
-from mudpy import log, on_pulse, reload_data, universe
-# loop indefinitely while the world is not flagged for termination or
-# there are connected users
-while not universe.terminate_world or universe.userlist:
+# log an initial message
+import sys
+mudpy.log(u"Started mudpy with command line: " + u" ".join(sys.argv))
- # the world was flagged for a reload of all code/data
- if universe.reload_modules:
+# fork and disassociate
+mudpy.daemonize()
- # reload the mudpy module
- reload(mudpy)
+# make the pidfile
+mudpy.create_pidfile(mudpy.universe)
- # move data into new persistent objects
- reload_data()
+# 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:
- # reset the reload flag
- universe.reload_modules = False
+ # 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
- on_pulse()
+ # do what needs to be done on each pulse
+ mudpy.on_pulse()
# the loop has terminated, so save persistent data
-universe.save()
+mudpy.universe.save()
# log a final message
-log("Shutting down now.")
+mudpy.log(u"Shutting down now.")
+
+# get rid of the pidfile
+mudpy.remove_pidfile(mudpy.universe)