-
Notifications
You must be signed in to change notification settings - Fork 3
/
gameserver.py
executable file
·79 lines (66 loc) · 2.4 KB
/
gameserver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import sys, signal
import time
sys.path.insert(0, '.')
sys.path.insert(1, 'game')
# Check for good enough Python version. Use builtin path.
# XXX: Should be killed before release.
if '__pypy__' in sys.builtin_module_names:
sys.path.insert(2, "/usr/local/lib/python3.4/dist-packages")
try:
import config
except ImportError:
print("You got no config.py file. Please make a file from config.py.dist")
sys.exit()
#### Try Cython? ####
if config.tryCython:
try:
import pyximport
pyximport.install(pyimport = True)
except ImportError:
print("Cython failed")
pass # No cython / old cython
# Fix log machinery by replacing tornado.concurrent.
# XXX: This might be tornado 4 specific. Be aware of bugs.
import game.hack_concurrent
#del sys.modules['tornado.concurrent']
sys.modules['tornado.concurrent'] = game.hack_concurrent
#### Import the tornado ####
from tornado.tcpserver import *
import tornado.gen
from service.gameserver import GameFactory
import time
import game.loading
import tornado.log
tornado.log.enable_pretty_logging()
startTime = time.time()
# Game Server
gameServer = GameFactory()
gameServer.bind(config.gamePort, config.gameInterface)
gameServer.start()
# (optionally) buildt in login server.
if config.letGameServerRunTheLoginServer:
from service.loginserver import LoginFactory
loginServer= LoginFactory()
loginServer.bind(config.loginPort, config.loginInterface)
loginServer.start()
# (optional) built in extension server.
# XXX Port later or kill?
#if config.enableExtensionProtocol:
# from service.extserver import ExtFactory
# extFactory = ExtFactory()
# tcpService = internet.TCPServer(config.loginPort + 10000, extFactory, interface=config.loginInterface)
# tcpService.setServiceParent(topService)
# (optional) built in extension server.
# XXX: Port later...
if config.enableWebProtocol:
from service.webserver import Web
from tornado import httpserver
webServer = tornado.httpserver.HTTPServer(Web)
webServer.bind(config.webPort, config.webInterface)
webServer.start()
# Load the core stuff!
IOLoop.instance().add_callback(game.loading.loader, startTime)
# Start reactor. This will call the above.
signal.signal(signal.SIGINT, game.scriptsystem.shutdown)
signal.signal(signal.SIGTERM, game.scriptsystem.shutdown)
IOLoop.instance().start()