kopia lustrzana https://github.com/OpenDroneMap/WebODM
Faster timeout on update_node_info(), oom preferences
rodzic
9a162841f1
commit
8317283b87
|
@ -14,3 +14,4 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- "3000"
|
- "3000"
|
||||||
restart: on-failure:10
|
restart: on-failure:10
|
||||||
|
oom_score_adj: 500
|
||||||
|
|
|
@ -13,6 +13,7 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- dbdata:/var/lib/postgresql/data
|
- dbdata:/var/lib/postgresql/data
|
||||||
restart: on-failure:10
|
restart: on-failure:10
|
||||||
|
oom_score_adj: -100
|
||||||
webapp:
|
webapp:
|
||||||
image: opendronemap/webodm_webapp
|
image: opendronemap/webodm_webapp
|
||||||
container_name: webapp
|
container_name: webapp
|
||||||
|
@ -31,10 +32,14 @@ services:
|
||||||
- WO_DEBUG
|
- WO_DEBUG
|
||||||
- WO_BROKER
|
- WO_BROKER
|
||||||
restart: on-failure:10
|
restart: on-failure:10
|
||||||
|
oom_score_adj: 0
|
||||||
broker:
|
broker:
|
||||||
image: redis
|
image: redis
|
||||||
container_name: broker
|
container_name: broker
|
||||||
restart: on-failure:10
|
restart: on-failure:10
|
||||||
|
mem_limit: 256m
|
||||||
|
oom_kill_disable: true
|
||||||
|
oom_score_adj: -500
|
||||||
worker:
|
worker:
|
||||||
image: opendronemap/webodm_webapp
|
image: opendronemap/webodm_webapp
|
||||||
container_name: worker
|
container_name: worker
|
||||||
|
@ -48,3 +53,4 @@ services:
|
||||||
- WO_BROKER
|
- WO_BROKER
|
||||||
- WO_DEBUG
|
- WO_DEBUG
|
||||||
restart: on-failure:10
|
restart: on-failure:10
|
||||||
|
oom_score_adj: 250
|
||||||
|
|
|
@ -9,12 +9,11 @@ import os
|
||||||
from urllib.parse import urlunparse
|
from urllib.parse import urlunparse
|
||||||
from app.testwatch import TestWatch
|
from app.testwatch import TestWatch
|
||||||
|
|
||||||
TIMEOUT = 30
|
|
||||||
|
|
||||||
class ApiClient:
|
class ApiClient:
|
||||||
def __init__(self, host, port):
|
def __init__(self, host, port, timeout=30):
|
||||||
self.host = host
|
self.host = host
|
||||||
self.port = port
|
self.port = port
|
||||||
|
self.timeout = timeout
|
||||||
|
|
||||||
def url(self, url):
|
def url(self, url):
|
||||||
netloc = self.host if self.port == 80 else "{}:{}".format(self.host, self.port)
|
netloc = self.host if self.port == 80 else "{}:{}".format(self.host, self.port)
|
||||||
|
@ -23,28 +22,28 @@ class ApiClient:
|
||||||
return urlunparse(('http', netloc, url, '', '', ''))
|
return urlunparse(('http', netloc, url, '', '', ''))
|
||||||
|
|
||||||
def info(self):
|
def info(self):
|
||||||
return requests.get(self.url('/info'), timeout=TIMEOUT).json()
|
return requests.get(self.url('/info'), timeout=self.timeout).json()
|
||||||
|
|
||||||
def options(self):
|
def options(self):
|
||||||
return requests.get(self.url('/options'), timeout=TIMEOUT).json()
|
return requests.get(self.url('/options'), timeout=self.timeout).json()
|
||||||
|
|
||||||
def task_info(self, uuid):
|
def task_info(self, uuid):
|
||||||
return requests.get(self.url('/task/{}/info').format(uuid), timeout=TIMEOUT).json()
|
return requests.get(self.url('/task/{}/info').format(uuid), timeout=self.timeout).json()
|
||||||
|
|
||||||
@TestWatch.watch()
|
@TestWatch.watch()
|
||||||
def task_output(self, uuid, line = 0):
|
def task_output(self, uuid, line = 0):
|
||||||
return requests.get(self.url('/task/{}/output?line={}').format(uuid, line), timeout=TIMEOUT).json()
|
return requests.get(self.url('/task/{}/output?line={}').format(uuid, line), timeout=self.timeout).json()
|
||||||
|
|
||||||
def task_cancel(self, uuid):
|
def task_cancel(self, uuid):
|
||||||
return requests.post(self.url('/task/cancel'), data={'uuid': uuid}, timeout=TIMEOUT).json()
|
return requests.post(self.url('/task/cancel'), data={'uuid': uuid}, timeout=self.timeout).json()
|
||||||
|
|
||||||
def task_remove(self, uuid):
|
def task_remove(self, uuid):
|
||||||
return requests.post(self.url('/task/remove'), data={'uuid': uuid}, timeout=TIMEOUT).json()
|
return requests.post(self.url('/task/remove'), data={'uuid': uuid}, timeout=self.timeout).json()
|
||||||
|
|
||||||
def task_restart(self, uuid, options = None):
|
def task_restart(self, uuid, options = None):
|
||||||
data = {'uuid': uuid}
|
data = {'uuid': uuid}
|
||||||
if options is not None: data['options'] = json.dumps(options)
|
if options is not None: data['options'] = json.dumps(options)
|
||||||
return requests.post(self.url('/task/restart'), data=data, timeout=TIMEOUT).json()
|
return requests.post(self.url('/task/restart'), data=data, timeout=self.timeout).json()
|
||||||
|
|
||||||
def task_download(self, uuid, asset):
|
def task_download(self, uuid, asset):
|
||||||
res = requests.get(self.url('/task/{}/download/{}').format(uuid, asset), stream=True)
|
res = requests.get(self.url('/task/{}/download/{}').format(uuid, asset), stream=True)
|
||||||
|
|
|
@ -66,7 +66,7 @@ class ProcessingNode(models.Model):
|
||||||
|
|
||||||
:returns: True if information could be updated, False otherwise
|
:returns: True if information could be updated, False otherwise
|
||||||
"""
|
"""
|
||||||
api_client = self.api_client()
|
api_client = self.api_client(timeout=5)
|
||||||
try:
|
try:
|
||||||
info = api_client.info()
|
info = api_client.info()
|
||||||
self.api_version = info['version']
|
self.api_version = info['version']
|
||||||
|
@ -80,8 +80,8 @@ class ProcessingNode(models.Model):
|
||||||
except (requests.exceptions.Timeout, requests.exceptions.ConnectionError, json.decoder.JSONDecodeError, simplejson.JSONDecodeError):
|
except (requests.exceptions.Timeout, requests.exceptions.ConnectionError, json.decoder.JSONDecodeError, simplejson.JSONDecodeError):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def api_client(self):
|
def api_client(self, timeout=30):
|
||||||
return ApiClient(self.hostname, self.port)
|
return ApiClient(self.hostname, self.port, timeout)
|
||||||
|
|
||||||
def get_available_options_json(self, pretty=False):
|
def get_available_options_json(self, pretty=False):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -326,6 +326,7 @@ CELERY_ACCEPT_CONTENT = ['json']
|
||||||
CELERY_INCLUDE=['worker.tasks']
|
CELERY_INCLUDE=['worker.tasks']
|
||||||
CELERY_WORKER_REDIRECT_STDOUTS = False
|
CELERY_WORKER_REDIRECT_STDOUTS = False
|
||||||
CELERY_WORKER_HIJACK_ROOT_LOGGER = False
|
CELERY_WORKER_HIJACK_ROOT_LOGGER = False
|
||||||
|
CELERY_TASK_RESULT_EXPIRES = 60
|
||||||
|
|
||||||
if TESTING:
|
if TESTING:
|
||||||
CELERY_TASK_ALWAYS_EAGER = True
|
CELERY_TASK_ALWAYS_EAGER = True
|
||||||
|
|
|
@ -52,7 +52,7 @@ start(){
|
||||||
action=$1
|
action=$1
|
||||||
|
|
||||||
echo "Starting worker using broker at $WO_BROKER"
|
echo "Starting worker using broker at $WO_BROKER"
|
||||||
celery -A worker worker --concurrency 1 --max-tasks-per-child 1000 --loglevel=warn > /dev/null
|
celery -A worker worker --autoscale $(grep -c '^processor' /proc/cpuinfo),2 --max-tasks-per-child 1000 --loglevel=warn > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
start_scheduler(){
|
start_scheduler(){
|
||||||
|
|
|
@ -79,7 +79,6 @@ def get_pending_tasks():
|
||||||
@app.task
|
@app.task
|
||||||
def process_pending_tasks():
|
def process_pending_tasks():
|
||||||
tasks = get_pending_tasks()
|
tasks = get_pending_tasks()
|
||||||
|
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
process_task.delay(task.id)
|
process_task.delay(task.id)
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue