Compare commits
17 Commits
queues
...
5fd8147ff3
| Author | SHA1 | Date | |
|---|---|---|---|
| 5fd8147ff3 | |||
| e7109cc254 | |||
| dc7c222f50 | |||
| 2d051a1881 | |||
| e6e3762768 | |||
| adc2525fab | |||
| 8a4a6ac217 | |||
| 3d379bc6d7 | |||
| 443b943bee | |||
| 1d543461e9 | |||
| 5967bc75d9 | |||
| 37ac151e68 | |||
| 53e929fe5a | |||
| f55b5f4841 | |||
| 7713d24b63 | |||
| 1c82ef3b2b | |||
| a76656716c |
@@ -10,7 +10,7 @@ services:
|
||||
TELEGRAM_TOKEN: $TELEGRAM_TOKEN_DEV
|
||||
STAGE: "development"
|
||||
networks:
|
||||
- queues
|
||||
- queues-development
|
||||
deploy:
|
||||
mode: replicated
|
||||
restart_policy:
|
||||
@@ -26,9 +26,9 @@ services:
|
||||
MONGO_HOST: "mongo.develop.sprinthub.ru"
|
||||
MONGO_PASSWORD: $MONGO_PASSWORD_DEV
|
||||
STAGE: "development"
|
||||
PLATFORM_SECURITY_TOKEN: $PLATFORM_SECURITY_TOKEN
|
||||
networks:
|
||||
- queues
|
||||
- queues-development
|
||||
- configurator
|
||||
deploy:
|
||||
mode: replicated
|
||||
restart_policy:
|
||||
@@ -44,7 +44,7 @@ services:
|
||||
TELEGRAM_TOKEN: $TELEGRAM_TOKEN_DEV
|
||||
STAGE: "development"
|
||||
networks:
|
||||
- queues
|
||||
- queues-development
|
||||
deploy:
|
||||
mode: replicated
|
||||
restart_policy:
|
||||
@@ -63,7 +63,7 @@ services:
|
||||
PLATFORM_SECURITY_TOKEN: $PLATFORM_SECURITY_TOKEN
|
||||
STAGE: "development"
|
||||
networks:
|
||||
- common-infra-nginx
|
||||
- common-infra-nginx-development
|
||||
deploy:
|
||||
mode: replicated
|
||||
restart_policy:
|
||||
@@ -73,7 +73,9 @@ services:
|
||||
order: start-first
|
||||
|
||||
networks:
|
||||
common-infra-nginx:
|
||||
common-infra-nginx-development:
|
||||
external: true
|
||||
queues:
|
||||
queues-development:
|
||||
external: true
|
||||
configurator:
|
||||
external: true
|
||||
|
||||
@@ -29,6 +29,7 @@ services:
|
||||
PLATFORM_SECURITY_TOKEN: $PLATFORM_SECURITY_TOKEN
|
||||
networks:
|
||||
- queues
|
||||
- configurator
|
||||
deploy:
|
||||
mode: replicated
|
||||
restart_policy:
|
||||
@@ -77,3 +78,5 @@ networks:
|
||||
external: true
|
||||
queues:
|
||||
external: true
|
||||
configurator:
|
||||
external: true
|
||||
|
||||
@@ -28,7 +28,7 @@ jobs:
|
||||
run: docker push mathwave/sprint-repo:pizda-bot
|
||||
deploy-dev:
|
||||
name: Deploy dev
|
||||
runs-on: [dev]
|
||||
runs-on: [prod]
|
||||
needs: push
|
||||
steps:
|
||||
- name: login
|
||||
@@ -42,4 +42,4 @@ jobs:
|
||||
TELEGRAM_TOKEN_DEV: ${{ secrets.TELEGRAM_TOKEN_DEV }}
|
||||
MONGO_PASSWORD_DEV: ${{ secrets.MONGO_PASSWORD_DEV }}
|
||||
PLATFORM_SECURITY_TOKEN: ${{ secrets.PLATFORM_SECURITY_TOKEN }}
|
||||
run: docker stack deploy --with-registry-auth -c ./.deploy/deploy-dev.yaml pizda-bot
|
||||
run: docker stack deploy --with-registry-auth -c ./.deploy/deploy-dev.yaml pizda-bot-development
|
||||
|
||||
@@ -14,11 +14,8 @@ class PlatformClient:
|
||||
self.stage = stage
|
||||
self.configs = configs
|
||||
self.experiments = experiments
|
||||
self.endpoint = 'https://platform.sprinthub.ru/'
|
||||
self.configs_url = urllib.parse.urljoin(self.endpoint, 'configs/get')
|
||||
self.experiments_url = urllib.parse.urljoin(self.endpoint, 'experiments/get')
|
||||
self.staff_url = urllib.parse.urljoin(self.endpoint, 'is_staff')
|
||||
self.fetch_url = urllib.parse.urljoin(self.endpoint, 'fetch')
|
||||
self.endpoint = 'http://configurator/'
|
||||
self.fetch_url = urllib.parse.urljoin(self.endpoint, '/api/v1/fetch')
|
||||
self.config_storage = {}
|
||||
self.experiment_storage = {}
|
||||
self.staff_storage = {}
|
||||
@@ -43,7 +40,6 @@ class PlatformClient:
|
||||
try:
|
||||
response = get(
|
||||
url,
|
||||
headers={'X-Security-Token': self.platform_security_token},
|
||||
params=params
|
||||
)
|
||||
if response.status_code == 200:
|
||||
|
||||
@@ -18,22 +18,22 @@ class QueuesException(Exception):
|
||||
class TasksHandlerMixin:
|
||||
def poll(self):
|
||||
while True:
|
||||
response = requests.get(f'{QUEUES_URL}/api/v1/take', headers={'queue': self.queue_name})
|
||||
if response.status_code == 404:
|
||||
response = requests.get(f'{QUEUES_URL}/api/v1/take', headers={'queue': self.queue_name}).json()
|
||||
task = response.get('task')
|
||||
if not task:
|
||||
time.sleep(0.2)
|
||||
continue
|
||||
data = response.json()
|
||||
try:
|
||||
self.process(data['payload'])
|
||||
self.process(task['payload'])
|
||||
except Exception as exc:
|
||||
print(f'Error processing message id={data["id"]}, payload={data["payload"]}, exc={exc}')
|
||||
print(f'Error processing message id={task["id"]}, payload={task["payload"]}, exc={exc}')
|
||||
continue
|
||||
try:
|
||||
resp = requests.post(f'{QUEUES_URL}/api/v1/finish', json={'id': data['id']})
|
||||
resp = requests.post(f'{QUEUES_URL}/api/v1/finish', json={'id': task['id']})
|
||||
if resp.status_code != 202:
|
||||
raise QueuesException
|
||||
except:
|
||||
print(f'Failed to finish task id={data["id"]}')
|
||||
print(f'Failed to finish task id={task["id"]}')
|
||||
|
||||
@property
|
||||
def queue_name(self):
|
||||
|
||||
Reference in New Issue
Block a user