Imported from archive.
[mudpy.git] / mudpy
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 u"""Skeletal executable for the mudpy engine."""
4
5 # Copyright (c) 2004-2009 Jeremy Stanley <fungi@yuggoth.org>. Permission
6 # to use, copy, modify, and distribute this software is granted under
7 # terms provided in the LICENSE file distributed with this software.
8
9 # core objects for the mudpy engine
10 import mudpy
11
12 # log an initial message
13 import sys
14 mudpy.log(u"Started mudpy with command line: " + u" ".join(sys.argv))
15
16 # fork and disassociate
17 mudpy.daemonize()
18
19 # make the pidfile
20 mudpy.create_pidfile(mudpy.universe)
21
22 # loop indefinitely while the world is not flagged for termination or
23 # there are still connected users
24 while not mudpy.universe.terminate_flag or mudpy.universe.userlist:
25
26    # the world was flagged for a reload of all code/data
27    if mudpy.universe.reload_flag: reload(mudpy)
28
29    # do what needs to be done on each pulse
30    mudpy.on_pulse()
31
32 # the loop has terminated, so save persistent data
33 mudpy.universe.save()
34
35 # log a final message
36 mudpy.log(u"Shutting down now.")
37
38 # get rid of the pidfile
39 mudpy.remove_pidfile(mudpy.universe)
40