forked from reimandlab/ActiveDriverDB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial implementation of task distribution reimandlab#122
- Loading branch information
1 parent
7bbfae0
commit 2df65cf
Showing
10 changed files
with
182 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,12 @@ sudo npm install -g autoprefixer postcss-cli nunjucks | |
# to be replaced with 'clean-css clean-css-cli' after a new release of webassets: | ||
# currently integration fails for new versions but the fix seems to be already implemented on master branch | ||
sudo npm install -g [email protected] | ||
|
||
# install broker for celery (note: command is Debian/Ubuntu specific) | ||
sudo apt-get install rabbitmq-server | ||
|
||
# generate keys (for testing only!) | ||
mkdir -p celery | ||
cd celery | ||
ssh-keygen -t rsa -f worker.key -N 'Password for testing only' | ||
cd .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from app import celery | ||
from app import create_app | ||
|
||
app = create_app() | ||
celery |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Adapted from flask.pocoo.org/docs/0.12/patterns/celery/ Flask documentation, | ||
therefore Flask documentation, BSD licence conditions may apply.""" | ||
import celery | ||
|
||
|
||
class Celery(celery.Celery): | ||
|
||
def init_app(self, app): | ||
self.__init__(app) | ||
|
||
def __init__(self, app=None): | ||
if app: | ||
super().__init__( | ||
app.import_name, | ||
backend=app.config['CELERY_RESULT_BACKEND'], | ||
broker=app.config['CELERY_BROKER_URL'] | ||
) | ||
self.conf.update(app.config) | ||
|
||
TaskBase = self.Task | ||
|
||
class ContextTask(TaskBase): | ||
abstract = True | ||
|
||
def __call__(self, *args, **kwargs): | ||
with app.app_context(): | ||
return TaskBase.__call__(self, *args, **kwargs) | ||
|
||
self.Task = ContextTask | ||
else: | ||
super().__init__() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,6 @@ jinja2_pluralize | |
yuicompressor | ||
flask-recaptcha | ||
flask-limiter | ||
flask_apscheduler | ||
flask_apscheduler | ||
celery | ||
amqp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{% extends 'base.html' %} | ||
|
||
|
||
{% block head %} | ||
{% if status in ['PENDING', 'PROGRESS'] %} | ||
<meta http-equiv="refresh" content="5"> | ||
{% endif %} | ||
{% endblock %} | ||
|
||
|
||
{% block content %} | ||
{% if status == 'PENDING' %} | ||
<p>Your search is queued. Please wait. The page will refresh itself every 5 seconds.</p> | ||
{% elif status == 'PROGRESS' %} | ||
<p>Your search is running: <span id="progress-percent">{{ progress }}</span>%</p> | ||
{% elif status == "FAILED" %} | ||
<p>The search failed</p> | ||
{% endif %} | ||
|
||
<div class="progress"> | ||
<div class="progress-bar progress-bar-striped active" id="progress-bar" role="progressbar" | ||
aria-valuenow="{{ progress }}" aria-valuemin="0" aria-valuemax="100" style="width:{{ progress }}%"> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters