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 | |||
0 ignored issues
–
show
|
|||
13 | import logging |
||
14 | from logging import handlers |
||
15 | import signal |
||
16 | import socket |
||
17 | |||
0 ignored issues
–
show
Unable to import 'games.game' (invalid syntax (<string>, line 146))
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 ![]() |
|||
18 | from server.game_service import GameService |
||
0 ignored issues
–
show
Unable to import 'stats.game_stats_service' (invalid syntax (<string>, line 15))
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 ![]() |
|||
19 | from server.matchmaker import MatchmakerQueue |
||
0 ignored issues
–
show
Unable to import 'gameconnection' (invalid syntax (<string>, line 96))
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 ![]() |
|||
20 | from server.player_service import PlayerService |
||
0 ignored issues
–
show
Unable to import 'natpacketserver' (invalid syntax (<string>, line 58))
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 ![]() |
|||
21 | from server.natpacketserver import NatPacketServer |
||
0 ignored issues
–
show
Unable to import 'lobbyconnection' (invalid syntax (<string>, line 128))
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 ![]() |
|||
22 | from server.stats.game_stats_service import GameStatsService, EventService, AchievementService |
||
23 | from server.api.api_accessor import ApiAccessor |
||
0 ignored issues
–
show
Unable to import 'servercontext' (invalid syntax (<string>, line 29))
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 ![]() |
|||
24 | import server |
||
0 ignored issues
–
show
Unable to import 'player_service' (invalid syntax (<string>, line 100))
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 ![]() |
|||
25 | import server.config as config |
||
0 ignored issues
–
show
Unable to import 'game_service' (invalid syntax (<string>, line 53))
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 ![]() |
|||
26 | from server.config import DB_SERVER, DB_PORT, DB_LOGIN, DB_PASSWORD, DB_NAME |
||
0 ignored issues
–
show
Unable to import 'ladder_service' (invalid syntax (<string>, line 30))
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 ![]() |
|||
27 | |||
0 ignored issues
–
show
Unable to import 'control' (invalid syntax (<string>, line 30))
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 ![]() |
|||
28 | if __name__ == '__main__': |
||
29 | logger = logging.getLogger() |
||
30 | stderr_handler = logging.StreamHandler() |
||
31 | stderr_handler.setFormatter(logging.Formatter('%(levelname)-8s %(name)-30s %(message)s')) |
||
32 | logger.addHandler(stderr_handler) |
||
33 | logger.setLevel(logging.DEBUG) |
||
34 | |||
35 | try: |
||
36 | def signal_handler(signal, frame): |
||
37 | logger.info("Received signal, shutting down") |
||
38 | if not done.done(): |
||
39 | done.set_result(0) |
||
40 | |||
0 ignored issues
–
show
|
|||
41 | loop = asyncio.get_event_loop() |
||
42 | done = asyncio.Future() |
||
43 | |||
44 | from docopt import docopt |
||
45 | args = docopt(__doc__, version='FAF Server') |
||
46 | |||
47 | logger.info("Using StatsD server: ".format(config.STATSD_SERVER)) |
||
48 | |||
49 | # Make sure we can shutdown gracefully |
||
50 | signal.signal(signal.SIGTERM, signal_handler) |
||
51 | signal.signal(signal.SIGINT, signal_handler) |
||
52 | |||
53 | pool_fut = asyncio.async(server.db.connect(host=DB_SERVER, |
||
54 | port=int(DB_PORT), |
||
55 | user=DB_LOGIN, |
||
56 | password=DB_PASSWORD, |
||
57 | maxsize=10, |
||
58 | db=DB_NAME, |
||
59 | loop=loop)) |
||
60 | db_pool = loop.run_until_complete(pool_fut) |
||
61 | |||
62 | players_online = PlayerService(db_pool) |
||
63 | api_accessor = ApiAccessor() |
||
64 | event_service = EventService(api_accessor) |
||
65 | achievement_service = AchievementService(api_accessor) |
||
66 | game_stats_service = GameStatsService(event_service, achievement_service) |
||
67 | |||
68 | natpacket_server = NatPacketServer(addresses=config.LOBBY_NAT_ADDRESSES, loop=loop) |
||
69 | loop.run_until_complete(natpacket_server.listen()) |
||
70 | server.NatPacketServer.instance = natpacket_server |
||
71 | |||
72 | games = GameService(players_online, game_stats_service) |
||
73 | matchmaker_queue = MatchmakerQueue('ladder1v1', players_online, games) |
||
74 | players_online.ladder_queue = matchmaker_queue |
||
75 | |||
76 | ctrl_server = loop.run_until_complete(server.run_control_server(loop, players_online, games)) |
||
77 | |||
78 | lobby_server = server.run_lobby_server(('', 8001), |
||
79 | players_online, |
||
80 | games, |
||
81 | loop) |
||
82 | |||
83 | for sock in lobby_server.sockets: |
||
84 | sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) |
||
85 | |||
86 | loop.run_until_complete(done) |
||
87 | players_online.broadcast_shutdown() |
||
88 | loop.close() |
||
89 | |||
90 | except Exception as ex: |
||
91 | logger.exception("Failure booting server {}".format(ex)) |
||
92 |
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.