Set game directory listing to update every 30 mins, changed setting to GAME_DIRECTORY_LISTING and removed too verbose logging.

This commit is contained in:
Griatch 2016-04-04 20:23:15 +02:00
parent bc04d5f99e
commit 8f1378c47e
3 changed files with 39 additions and 34 deletions

View file

@ -3,28 +3,28 @@
Greg Taylor 2016 Greg Taylor 2016
This contrib features a client for the [Evennia Game Directory] This contrib features a client for the [Evennia Game Directory]
(http://evennia-game-directory.appspot.com/), a listing of games built on (http://evennia-game-directory.appspot.com/), a listing of games built on
Evennia. By listing your game on the directory, you make it easy for other Evennia. By listing your game on the directory, you make it easy for other
people in the community to discover your creation. people in the community to discover your creation.
*Note: Since this is still an early experiment, there is no notion of *Note: Since this is still an early experiment, there is no notion of
ownership for a game listing. As a consequence, we rely on the good behavior ownership for a game listing. As a consequence, we rely on the good behavior
of our users in the early goings. If the directory is a success, we'll work of our users in the early goings. If the directory is a success, we'll work
on remedying this.* on remedying this.*
## Listing your Game ## Listing your Game
To list your game, you'll need to enable the Evennia Game Directory client. To list your game, you'll need to enable the Evennia Game Directory client.
Start by `cd`'ing to your game directory. From there, open up Start by `cd`'ing to your game directory. From there, open up
`server/conf/server_services_plugins.py`. It might look something like this `server/conf/server_services_plugins.py`. It might look something like this
if you don't have any other optional add-ons enabled: if you don't have any other optional add-ons enabled:
""" """
Server plugin services Server plugin services
This plugin module can define user-created services for the Server to This plugin module can define user-created services for the Server to
start. start.
This module must handle all imports and setups required to start a This module must handle all imports and setups required to start a
twisted service (see examples in evennia.server.server). It must also twisted service (see examples in evennia.server.server). It must also
contain a function start_plugin_services(application). Evennia will contain a function start_plugin_services(application). Evennia will
@ -32,26 +32,26 @@ if you don't have any other optional add-ons enabled:
can be added to it). The function should not return anything. Plugin can be added to it). The function should not return anything. Plugin
services are started last in the Server startup process. services are started last in the Server startup process.
""" """
def start_plugin_services(server): def start_plugin_services(server):
""" """
This hook is called by Evennia, last in the Server startup process. This hook is called by Evennia, last in the Server startup process.
server - a reference to the main server application. server - a reference to the main server application.
""" """
pass pass
To enable the client, import `EvenniaGameDirService` and fire it up after the To enable the client, import `EvenniaGameDirService` and fire it up after the
Evennia server has finished starting: Evennia server has finished starting:
""" """
Server plugin services Server plugin services
This plugin module can define user-created services for the Server to This plugin module can define user-created services for the Server to
start. start.
This module must handle all imports and setups required to start a This module must handle all imports and setups required to start a
twisted service (see examples in evennia.server.server). It must also twisted service (see examples in evennia.server.server). It must also
contain a function start_plugin_services(application). Evennia will contain a function start_plugin_services(application). Evennia will
@ -59,13 +59,13 @@ Evennia server has finished starting:
can be added to it). The function should not return anything. Plugin can be added to it). The function should not return anything. Plugin
services are started last in the Server startup process. services are started last in the Server startup process.
""" """
from evennia.contrib.gamedir_client import EvenniaGameDirService from evennia.contrib.gamedir_client import EvenniaGameDirService
def start_plugin_services(server): def start_plugin_services(server):
""" """
This hook is called by Evennia, last in the Server startup process. This hook is called by Evennia, last in the Server startup process.
server - a reference to the main server application. server - a reference to the main server application.
""" """
gamedir_service = EvenniaGameDirService() gamedir_service = EvenniaGameDirService()
@ -74,12 +74,12 @@ Evennia server has finished starting:
Next, configure your game listing by opening up `server/conf/settings.py` and Next, configure your game listing by opening up `server/conf/settings.py` and
using the following as a starting point: using the following as a starting point:
###################################################################### ######################################################################
# Contrib config # Contrib config
###################################################################### ######################################################################
GAMEDIR_CLIENT = { GAME_DIRECTORY_LISTING = {
'game_status': 'pre-alpha', 'game_status': 'pre-alpha',
'listing_contact': 'me@my-game.com', 'listing_contact': 'me@my-game.com',
'telnet_hostname': 'my-game.com', 'telnet_hostname': 'my-game.com',
@ -88,11 +88,11 @@ Next, configure your game listing by opening up `server/conf/settings.py` and
The following section in this README.md will go over all possible values. The following section in this README.md will go over all possible values.
At this point, you should be all set! Simply restart your game and check the At this point, you should be all set! Simply restart your game and check the
server logs for errors. Your listing and some game state will be sent every server logs for errors. Your listing and some game state will be sent every
half hour. half hour.
## Possible GAMEDIR_CLIENT settings ## Possible GAMEDIR_DIRECTORY_LISTING settings
### game_status ### game_status
@ -128,12 +128,12 @@ The port that the players can telnet into to play your game.
## What information is being reported? ## What information is being reported?
In addition the the details listed in the previous section, we send some In addition the the details listed in the previous section, we send some
simple usage stats that don't currently get displayed. These will help the simple usage stats that don't currently get displayed. These will help the
Evennia maintainers get a feel for some technical specifics for games out in Evennia maintainers get a feel for some technical specifics for games out in
the wild. the wild.
## Troubleshooting ## Troubleshooting
If you don't see your game appear on the listing, check your server logs. You If you don't see your game appear on the listing, check your server logs. You
should see some error messages. should see some error messages.

View file

@ -29,6 +29,7 @@ class EvenniaGameDirClient(object):
self.report_host = 'http://evennia-game-directory.appspot.com' self.report_host = 'http://evennia-game-directory.appspot.com'
self.report_path = '/api/v1/game/check_in' self.report_path = '/api/v1/game/check_in'
self.report_url = self.report_host + self.report_path self.report_url = self.report_host + self.report_path
self.logged_first_connect = False
self._on_bad_request = on_bad_request self._on_bad_request = on_bad_request
# Oh, the humanity. Silence the factory start/stop messages. # Oh, the humanity. Silence the factory start/stop messages.
@ -43,8 +44,10 @@ class EvenniaGameDirClient(object):
""" """
status_code, response_body = yield self._form_and_send_request() status_code, response_body = yield self._form_and_send_request()
if status_code == 200: if status_code == 200:
logger.log_infomsg( if not self.logged_first_connect:
"Successfully sent game details to Evennia Game Directory.") logger.log_infomsg(
"Successfully sent game details to Evennia Game Directory.")
self.logged_first_connect = True
return return
# At this point, either EGD is having issues or the payload we sent # At this point, either EGD is having issues or the payload we sent
# is improperly formed (probably due to mis-configuration). # is improperly formed (probably due to mis-configuration).
@ -64,7 +67,7 @@ class EvenniaGameDirClient(object):
'User-Agent': ['Evennia Game Directory Client'], 'User-Agent': ['Evennia Game Directory Client'],
'Content-Type': ['application/x-www-form-urlencoded'], 'Content-Type': ['application/x-www-form-urlencoded'],
} }
gd_config = settings.GAMEDIR_CLIENT gd_config = settings.GAME_DIRECTORY_LISTING
values = { values = {
'game_name': settings.SERVERNAME, 'game_name': settings.SERVERNAME,
'game_status': gd_config['game_status'], 'game_status': gd_config['game_status'],

View file

@ -4,6 +4,8 @@ from twisted.internet.task import LoopingCall
from evennia.contrib.gamedir_client.client import EvenniaGameDirClient from evennia.contrib.gamedir_client.client import EvenniaGameDirClient
from evennia.utils import logger from evennia.utils import logger
# How often to sync to the server
_CLIENT_UPDATE_RATE = 60 * 30
class EvenniaGameDirService(Service): class EvenniaGameDirService(Service):
""" """
@ -20,7 +22,7 @@ class EvenniaGameDirService(Service):
def startService(self): def startService(self):
super(EvenniaGameDirService, self).startService() super(EvenniaGameDirService, self).startService()
# TODO: Check to make sure that the client is configured. # TODO: Check to make sure that the client is configured.
self.loop.start(10) self.loop.start(_CLIENT_UPDATE_RATE)
def stopService(self): def stopService(self):
if self.running == 0: if self.running == 0: