Skip to content

Instantly share code, notes, and snippets.

@anjensan
Last active June 17, 2016 10:15
Show Gist options
  • Save anjensan/b5c8588c2dbc17747d78359281f0429c to your computer and use it in GitHub Desktop.
Save anjensan/b5c8588c2dbc17747d78359281f0429c to your computer and use it in GitHub Desktop.
# coding: utf-8
from twisted.application import internet, service
from twoost.app import * # noqa
from twoost.log import setup_logging
from demoapp.app import init_demoapp_settings
from demoapp.dao import DBDaoService
from demoapp.storage import StorageService
setup_logging('demoapp-storage')
init_demoapp_settings()
application = service.Application('demoapp-storage')
dbs = build_dbs(application, ['default'])
amqps = build_amqps(application, ['default'])
memcache = build_memcache(application)
dao = attach_service(application, DBDaoService(dbs=dbs, memcache=memcache))
dbw_service = attach_service(application, StorageService(dao=dao))
amqps['default'].setupQueueConsuming(
queue='incoming_events',
callback=dbw_service.process_event,
parallel=5, # how many messages we can process at the same time
)
# ...
[program:demoapp-storage]
command=twistd --nodaemon --pidfile=/tmp/demoapp/%(program_name)-%(process_num).pid --python=path/to/demoapp-storage.tac
process_name=%(program_name)-%(process_num)
numprocs=5
environment=TWOOST_WORKERID="%(program_name)-%(process_num)"
# other args...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment