Made the evennia launcher menu work correctly again.

This commit is contained in:
Griatch 2015-01-18 22:49:18 +01:00
parent 4bc39029f1
commit 3159ceceaa

View file

@ -199,57 +199,46 @@ ABOUT_INFO= \
""" """
HELP_ENTRY = \ HELP_ENTRY = \
""" """
See python evennia.py -h for controlling Evennia directly from Enter 'evennia -h' for command-line options.
the command line.
Evennia has two parts that both must run: Use option (1) in a production environment. During development (2) is
usually enough, portal debugging is usually only useful if you are
adding new protocols or are debugging Evennia itself.
Portal - the connection to the outside world (via telnet, web, ssh Reload with (5) to update the server with your changes without
etc). This is normally running as a daemon and don't need to disconnecting any players.
be reloaded unless you are debugging a new connection
protocol.
Server - the game server itself. This will often need to be reloaded
as you develop your game. The Portal will auto-connect to the
Server whenever the Server activates.
Use option (1) in a production environment. During development (2) is Note: Reload and stop are sometimes poorly supported in Windows. If you have
usually enough, portal debugging is usually only useful if you are issues, log into the game to stop or restart the server instead.
adding new protocols or are debugging an Evennia bug. """
Reload with (5) to update the server with your changes without
disconnecting any players.
Reload and stop are sometimes poorly supported in Windows. If you have
issues, log into the game to stop or restart the server instead.
"""
MENU = \ MENU = \
""" """
+----Evennia Launcher-------------------------------------------------------+ +----Evennia Launcher-------------------------------------------+
| | | |
+--- Starting --------------------------------------------------------------+ +--- Starting --------------------------------------------------+
| | | |
| 1) (default): All output to logfiles. | | 1) (normal): All output to logfiles |
| 2) (game debug): Server outputs to terminal instead of to logfile. | | 2) (server devel): Server logs to terminal (-i option) |
| 3) (portal debug): Portal outputs to terminal instead of to logfile. | | 3) (portal devel): Portal logs to terminal |
| 4) (full debug): Both Server and Portal output to terminal | | 4) (full devel): Both Server and Portal logs to terminal |
| | | |
+--- Restarting ------------------------------------------------------------+ +--- Restarting ------------------------------------------------+
| | | |
| 5) Reload the Server | | 5) Reload the Server |
| 6) Reload the Portal (only works with portal/full debug) | | 6) Reload the Portal (only works with portal/full debug) |
| | | |
+--- Stopping --------------------------------------------------------------+ +--- Stopping --------------------------------------------------+
| | | |
| 7) Stopping both Portal and Server. | | 7) Stopping both Portal and Server |
| 8) Stopping only Server. | | 8) Stopping only Server |
| 9) Stopping only Portal. | | 9) Stopping only Portal |
| | | |
+---------------------------------------------------------------------------+ +---------------------------------------------------------------+
| h) Help i) About info q) Abort | | h) Help i) About info q) Abort |
+---------------------------------------------------------------------------+ +---------------------------------------------------------------+
""" """
ERROR_PYTHON_VERSION = \ ERROR_PYTHON_VERSION = \
""" """
@ -709,9 +698,6 @@ def run_menu():
""" """
This launches an interactive menu. This launches an interactive menu.
""" """
cmdstr = [sys.executable, EVENNIA_RUNNER]
while True: while True:
# menu loop # menu loop
@ -720,9 +706,9 @@ def run_menu():
# quitting and help # quitting and help
if inp.lower() == 'q': if inp.lower() == 'q':
sys.exit() return
elif inp.lower() == 'h': elif inp.lower() == 'h':
print HELP_ENTRY % EVENNIA_VERSION print HELP_ENTRY
raw_input("press <return> to continue ...") raw_input("press <return> to continue ...")
continue continue
elif inp.lower() in ('v', 'i', 'a'): elif inp.lower() in ('v', 'i', 'a'):
@ -736,41 +722,39 @@ def run_menu():
except ValueError: except ValueError:
print "Not a valid option." print "Not a valid option."
continue continue
errmsg = "The %s does not seem to be running." if inp == 1:
if inp < 5: # start everything, log to log files
if inp == 1: server_operation("start", "all", False, False)
pass # default operation elif inp == 2:
elif inp == 2: # start everything, server interactive start
cmdstr.extend(['--iserver']) server_operation("start", "all", True, False)
elif inp == 3: elif inp == 3:
cmdstr.extend(['--iportal']) # start everything, portal interactive start
elif inp == 4: server_operation("start", "server", False, False)
cmdstr.extend(['--iserver', '--iportal']) server_operation("start", "portal", True, False)
# start server elif inp == 4:
cmdstr.append("start") # start both server and portal interactively
Popen(cmdstr, env=getenv()) server_operation("start", "server", True, False)
return server_operation("start", "portal", True, False)
elif inp < 10: elif inp == 5:
if inp == 5: # reload the server
if os.name == 'nt': server_operation("reload", "server", None, None)
print "This operation is not supported under Windows. Log into the game to restart/reload the server." elif inp == 6:
return # reload the portal
kill(SERVER_PIDFILE, SIG, "Server reloaded.", errmsg % "Server", SERVER_RESTART, restart=True) server_operation("reload", "portal", None, None)
elif inp == 6: elif inp == 7:
if os.name == 'nt': # stop server and portal
print "This operation is not supported under Windows." server_operation("stop", "all", None, None)
return elif inp == 8:
kill(PORTAL_PIDFILE, SIG, "Portal reloaded (or stopped if in daemon mode).", errmsg % "Portal", PORTAL_RESTART, restart=True) # stop server
elif inp == 7: server_operation("stop", "server", None, None)
kill(PORTAL_PIDFILE, SIG, "Stopped Portal.", errmsg % "Portal", PORTAL_RESTART) elif inp == 9:
kill(SERVER_PIDFILE, SIG, "Stopped Server.", errmsg % "Server", SERVER_RESTART) # stop portal
elif inp == 8: server_operation("stop", "portal", None, None)
kill(SERVER_PIDFILE, SIG, "Stopped Server.", errmsg % "Server", SERVER_RESTART)
elif inp == 9:
kill(PORTAL_PIDFILE, SIG, "Stopped Portal.", errmsg % "Portal", PORTAL_RESTART)
return
else: else:
print "Not a valid option." print "Not a valid option."
continue
return
def server_operation(mode, service, interactive, profiler): def server_operation(mode, service, interactive, profiler):