Skip to content

Commit

Permalink
update config for synse v3 (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
edaniszewski authored May 14, 2019
1 parent 2121107 commit 28f3987
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
1 change: 0 additions & 1 deletion synse_server/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
)

device_cache = aiocache.SimpleMemoryCache(
ttl=config.options.get('cache.device.ttl', None),
namespace=NS_DEVICE,
)

Expand Down
4 changes: 2 additions & 2 deletions synse_server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
)),
)),
DictOption('cache', default=None, scheme=Scheme(
DictOption('meta', scheme=Scheme(
Option('ttl', default=20, field_type=int)
DictOption('device', scheme=Scheme(
Option('rebuild_every', default=180, field_type=int) # three minutes
)),
DictOption('transaction', scheme=Scheme(
Option('ttl', default=300, field_type=int) # five minutes
Expand Down
6 changes: 5 additions & 1 deletion synse_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sanic_prometheus import monitor

import synse_server
from synse_server import app, config, plugin
from synse_server import app, config, plugin, tasks
from synse_server.i18n import _
from synse_server.log import logger, setup_logger

Expand Down Expand Up @@ -105,6 +105,10 @@ def run(self):
if self.log_header:
sys.stdout.write(self._header)

# Add background tasks. This needs to be done at run so any tasks
# that take config options have the loaded config available to them.
tasks.register_with_app(self.app)

# If application metrics are enabled, configure the application now.
if config.options.get('metrics.enabled'):
logger.info(_('application performance metrics enabled'))
Expand Down
3 changes: 2 additions & 1 deletion synse_server/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import asyncio

from synse_server import config
from synse_server.cache import update_device_cache
from synse_server.i18n import _
from synse_server.log import logger
Expand All @@ -20,7 +21,7 @@ def register_with_app(app):

async def _rebuild_device_cache():
"""Periodically rebuild the device cache."""
interval = 3 * 60 # 3 minutes
interval = config.options.get('cache.device.rebuild_every', 3 * 60) # 3 minute default

while True:
logger.info(
Expand Down

0 comments on commit 28f3987

Please sign in to comment.