Update ccc.py
Browse files
ccc.py
CHANGED
@@ -1,15 +1,22 @@
|
|
1 |
import aiohttp
|
2 |
-
import time
|
3 |
import asyncio
|
4 |
import random
|
5 |
import multiprocessing
|
6 |
from dateutil import parser
|
7 |
import os
|
8 |
import logging
|
|
|
|
|
9 |
|
10 |
# Disable all logging except for critical errors
|
11 |
logging.basicConfig(level=logging.CRITICAL)
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
discord_webhook_url = os.environ['webhook']
|
14 |
api_batch_url = "https://epic-alligator-77.deno.dev/post"
|
15 |
asset_info_url = "https://economy.roproxy.com/v2/assets/"
|
@@ -142,21 +149,38 @@ async def print_status_periodically():
|
|
142 |
print("Working")
|
143 |
await asyncio.sleep(60)
|
144 |
|
145 |
-
def
|
146 |
-
asyncio.run(run_scanner_instance(digit))
|
147 |
-
|
148 |
-
if __name__ == "__main__":
|
149 |
initialize_base_ids()
|
150 |
-
|
151 |
instances_per_digit = 20000
|
152 |
|
153 |
for i in range(instances_per_digit):
|
154 |
digit = 7 + (i % 8)
|
155 |
-
|
156 |
-
|
157 |
-
|
|
|
158 |
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
-
|
162 |
-
|
|
|
1 |
import aiohttp
|
|
|
2 |
import asyncio
|
3 |
import random
|
4 |
import multiprocessing
|
5 |
from dateutil import parser
|
6 |
import os
|
7 |
import logging
|
8 |
+
from fastapi import FastAPI
|
9 |
+
import uvicorn
|
10 |
|
11 |
# Disable all logging except for critical errors
|
12 |
logging.basicConfig(level=logging.CRITICAL)
|
13 |
|
14 |
+
app = FastAPI()
|
15 |
+
|
16 |
+
@app.get("/")
|
17 |
+
async def root():
|
18 |
+
return {"status": "running"}
|
19 |
+
|
20 |
discord_webhook_url = os.environ['webhook']
|
21 |
api_batch_url = "https://epic-alligator-77.deno.dev/post"
|
22 |
asset_info_url = "https://economy.roproxy.com/v2/assets/"
|
|
|
149 |
print("Working")
|
150 |
await asyncio.sleep(60)
|
151 |
|
152 |
+
async def scanner_main():
|
|
|
|
|
|
|
153 |
initialize_base_ids()
|
154 |
+
tasks = []
|
155 |
instances_per_digit = 20000
|
156 |
|
157 |
for i in range(instances_per_digit):
|
158 |
digit = 7 + (i % 8)
|
159 |
+
tasks.append(run_scanner_instance(digit))
|
160 |
+
|
161 |
+
tasks.append(print_status_periodically())
|
162 |
+
await asyncio.gather(*tasks)
|
163 |
|
164 |
+
def run_server_and_scanner():
|
165 |
+
loop = asyncio.new_event_loop()
|
166 |
+
asyncio.set_event_loop(loop)
|
167 |
+
|
168 |
+
scanner_task = loop.create_task(scanner_main())
|
169 |
+
api_task = loop.create_task(
|
170 |
+
uvicorn.run(
|
171 |
+
app,
|
172 |
+
host="0.0.0.0",
|
173 |
+
port=7860,
|
174 |
+
loop=loop
|
175 |
+
)
|
176 |
+
)
|
177 |
+
|
178 |
+
try:
|
179 |
+
loop.run_forever()
|
180 |
+
except KeyboardInterrupt:
|
181 |
+
pass
|
182 |
+
finally:
|
183 |
+
loop.close()
|
184 |
|
185 |
+
if __name__ == "__main__":
|
186 |
+
run_server_and_scanner()
|