From 67db33b3ae0b56e0d559dc88a307c5f765bde643 Mon Sep 17 00:00:00 2001 From: sgm Date: Thu, 10 May 2012 15:07:12 +0900 Subject: [PATCH] =?UTF-8?q?wsgi=EC=97=90=20bot=20=EC=8B=A4=ED=96=89=20?= =?UTF-8?q?=ED=86=B5=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- README | 1 + bot.py | 2 +- config.py.example | 1 + wsgi.py | 5 ++++- 5 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 README diff --git a/.gitignore b/.gitignore index 46d7363..13f461a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ config.py -config.pyc +*.pyc diff --git a/README b/README new file mode 100644 index 0000000..db06912 --- /dev/null +++ b/README @@ -0,0 +1 @@ +python wsgi.py diff --git a/bot.py b/bot.py index 13bcb72..408ebe9 100644 --- a/bot.py +++ b/bot.py @@ -19,7 +19,7 @@ def __init__(self): self.connected = False connection = pymongo.Connection() - self.db = connection.sirc_db + self.db = connection[config.SIRC_DB] self.db.send.remove() self._fetch() diff --git a/config.py.example b/config.py.example index 34a6548..049465c 100644 --- a/config.py.example +++ b/config.py.example @@ -3,6 +3,7 @@ # SIRC N_LINES = 32 SIRC_PORT = 2354 +SIRC_DB = 'sirc_db' # IRC SERVER = 'irc.uriirc.org' diff --git a/wsgi.py b/wsgi.py index 8c04100..12c763d 100644 --- a/wsgi.py +++ b/wsgi.py @@ -17,9 +17,10 @@ sys.path.append(PATH) import config +import bot con = pymongo.Connection() -db = con.sirc_db +db = con[config.SIRC_DB] def application(environ, start_response): cookie = Cookie.SimpleCookie() @@ -285,6 +286,8 @@ def remove_invalid_utf8_char(s): return pattern.sub(u'�', s) if __name__ == '__main__': + bot = bot.SBot() + gevent.spawn(bot.start) server = gevent.pywsgi.WSGIServer(('0.0.0.0', config.SIRC_PORT), application) server.serve_forever()