Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fb9f02d

Browse files
blacklist, index performance, ping
1 parent 4cdba90 commit fb9f02d

File tree

2 files changed

+44
-15
lines changed

2 files changed

+44
-15
lines changed

‎web/server.py‎

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,6 @@ def data_received(self, chunk):
5555
pass
5656

5757

58-
class IndexHandler(BaseHandler):
59-
@gen.coroutine
60-
def get(self):
61-
with open("index.html") as f:
62-
html = f.read()
63-
self.write(html)
64-
65-
6658
class AntiCrawler:
6759

6860
def __init__(self, instance):
@@ -126,8 +118,23 @@ def get_real_ip(self):
126118
return x_real or remote_ip
127119

128120

121+
class IndexHandler(BaseHandler):
122+
executor = ThreadPoolExecutor(100)
123+
124+
@run_on_executor()
125+
def send_index(self):
126+
with open("index.html") as f:
127+
html = f.read()
128+
return html
129+
130+
@gen.coroutine
131+
def get(self):
132+
resp = yield self.send_index()
133+
self.write(resp)
134+
135+
129136
class ResourceHandler(BaseHandler):
130-
executor = ThreadPoolExecutor(50)
137+
executor = ThreadPoolExecutor(100)
131138

132139
@run_on_executor()
133140
def get_resource_data(self):
@@ -193,7 +200,7 @@ def get(self):
193200

194201

195202
class TopHandler(BaseHandler):
196-
executor = ThreadPoolExecutor(50)
203+
executor = ThreadPoolExecutor(100)
197204

198205
@run_on_executor()
199206
def get_top_resource(self):
@@ -219,7 +226,7 @@ def get(self):
219226

220227

221228
class NameHandler(BaseHandler):
222-
executor = ThreadPoolExecutor(50)
229+
executor = ThreadPoolExecutor(100)
223230

224231
@staticmethod
225232
def json_encode(value):
@@ -272,7 +279,7 @@ def get(self):
272279

273280

274281
class MetricsHandler(BaseHandler):
275-
executor = ThreadPoolExecutor(50)
282+
executor = ThreadPoolExecutor(100)
276283

277284
@classmethod
278285
def add(cls, type_name):
@@ -304,6 +311,29 @@ def post(self):
304311
self.write(resp)
305312

306313

314+
class BlacklistHandler(BaseHandler):
315+
executor = ThreadPoolExecutor(100)
316+
317+
@run_on_executor()
318+
def get_black_list(self):
319+
r = Redis().r
320+
321+
keys = r.keys("*")
322+
result = {}
323+
324+
for key in keys:
325+
count = r.get(key)
326+
ttl = r.ttl(key)
327+
result["key"] = dict(count=count, ttl=ttl)
328+
329+
return result
330+
331+
@gen.coroutine
332+
def get(self):
333+
resp = yield self.get_black_list()
334+
self.write(resp)
335+
336+
307337
class RunServer:
308338
root_path = os.path.dirname(__file__)
309339
static_path = os.path.join(root_path, '')
@@ -312,6 +342,7 @@ class RunServer:
312342
(r'/api/top', TopHandler),
313343
(r'/api/name', NameHandler),
314344
(r'/api/metrics', MetricsHandler),
345+
(r'/api/blacklist', BlacklistHandler),
315346
(r'/', IndexHandler),
316347
(r'/(.*\.html|.*\.js|.*\.css|.*\.png|.*\.jpg|.*\.ico|.*\.gif|.*\.woff2)', web.StaticFileHandler,
317348
{'path': static_path}),

‎yyetsbot/bot.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,14 @@ def send_ping(message):
6060
bot.send_chat_action(message.chat.id, 'typing')
6161

6262
info = get_runtime("botsrunner_yyets_1")
63-
redis = get_runtime("botsrunner_redis_1", "Redis")
64-
mongo = get_runtime("botsrunner_mongo_1", "MongoDB")
6563

6664
usage = ""
6765
if str(message.chat.id) == MAINTAINER:
6866
usage = show_usage()
6967
announcement = redis_announcement() or ""
7068
if announcement:
7169
announcement = f"\n\n*公告:{announcement}*\n\n"
72-
bot.send_message(message.chat.id, f"{info}\n{redis}\n{mongo}\n{usage}\n{announcement}",
70+
bot.send_message(message.chat.id, f"{info}\n\n{usage}\n{announcement}",
7371
parse_mode='markdown')
7472

7573

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /