1 | #!/usr/bin/env python3 |
||
2 | """ |
||
3 | Usage: |
||
4 | server.py [--nodb | --db TYPE] |
||
5 | |||
6 | Options: |
||
7 | --nodb Don't use a database (Use a mock.Mock). Caution: Will break things. |
||
8 | --db TYPE Use TYPE database driver [default: QMYSQL] |
||
9 | """ |
||
10 | |||
11 | import asyncio |
||
12 | |||
13 | import logging |
||
14 | from logging import handlers |
||
15 | import signal |
||
16 | import socket |
||
17 | |||
0 ignored issues
–
show
|
|||
18 | from server.game_service import GameService |
||
19 | from server.matchmaker import MatchmakerQueue |
||
20 | from server.player_service import PlayerService |
||
21 | from server.natpacketserver import NatPacketServer |
||
22 | from server.stats.game_stats_service import GameStatsService, EventService, AchievementService |
||
23 | from server.api.api_accessor import ApiAccessor |
||
24 | import server |
||
0 ignored issues
–
show
Unable to import 'player_service' (invalid syntax (<string>, line 97))
This can be caused by one of the following: 1. Missing DependenciesThis error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands. # .scrutinizer.yml
before_commands:
- sudo pip install abc # Python2
- sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use
the command for the correct version.
2. Missing __init__.py filesThis error could also result from missing
Loading history...
|
|||
25 | import server.config as config |
||
26 | from server.config import DB_SERVER, DB_PORT, DB_LOGIN, DB_PASSWORD, DB_NAME |
||
27 | |||
28 | if __name__ == '__main__': |
||
29 | logger = logging.getLogger() |
||
30 | stderr_handler = logging.StreamHandler() |
||
31 | logger.addHandler(stderr_handler) |
||
32 | logger.setLevel(logging.DEBUG) |
||
33 | |||
34 | try: |
||
35 | def signal_handler(signal, frame): |
||
36 | logger.info("Received signal, shutting down") |
||
37 | if not done.done(): |
||
38 | done.set_result(0) |
||
39 | |||
40 | loop = asyncio.get_event_loop() |
||
41 | done = asyncio.Future() |
||
42 | |||
43 | from docopt import docopt |
||
44 | args = docopt(__doc__, version='FAF Server') |
||
45 | |||
46 | logger.info("Using StatsD server: ".format(config.STATSD_SERVER)) |
||
47 | |||
48 | # Make sure we can shutdown gracefully |
||
49 | signal.signal(signal.SIGTERM, signal_handler) |
||
50 | signal.signal(signal.SIGINT, signal_handler) |
||
51 | |||
52 | pool_fut = asyncio.async(server.db.connect(host=DB_SERVER, |
||
53 | port=int(DB_PORT), |
||
54 | user=DB_LOGIN, |
||
55 | password=DB_PASSWORD, |
||
56 | maxsize=10, |
||
57 | db=DB_NAME, |
||
58 | loop=loop)) |
||
59 | db_pool = loop.run_until_complete(pool_fut) |
||
60 | |||
61 | players_online = PlayerService(db_pool) |
||
62 | api_accessor = ApiAccessor() |
||
63 | event_service = EventService(api_accessor) |
||
64 | achievement_service = AchievementService(api_accessor) |
||
65 | game_stats_service = GameStatsService(event_service, achievement_service) |
||
66 | |||
67 | natpacket_server = NatPacketServer(addresses=config.LOBBY_NAT_ADDRESSES, loop=loop) |
||
68 | loop.run_until_complete(natpacket_server.listen()) |
||
69 | server.NatPacketServer.instance = natpacket_server |
||
70 | |||
71 | games = GameService(players_online, game_stats_service) |
||
72 | matchmaker_queue = MatchmakerQueue('ladder1v1', players_online, games) |
||
73 | players_online.ladder_queue = matchmaker_queue |
||
74 | |||
75 | ctrl_server = loop.run_until_complete(server.run_control_server(loop, players_online, games)) |
||
76 | |||
77 | lobby_server = server.run_lobby_server(('', 8001), |
||
78 | players_online, |
||
79 | games, |
||
80 | loop) |
||
81 | |||
82 | for sock in lobby_server.sockets: |
||
83 | sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) |
||
84 | |||
85 | loop.run_until_complete(done) |
||
86 | loop.close() |
||
87 | |||
88 | except Exception as ex: |
||
89 | logger.exception("Failure booting server {}".format(ex)) |
||
90 |
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.py
files in your module folders. Make sure that you place one file in each sub-folder.