Deprecate old runworkers command.

This commit is contained in:
Arik Fraimovich
2014-05-16 17:57:43 +03:00
parent 9636359497
commit 9de6996dc8
3 changed files with 14 additions and 32 deletions

View File

@@ -2,10 +2,7 @@
""" """
CLI to manage redash. CLI to manage redash.
""" """
import signal from redash import settings, app, db, models, __version__
import logging
import time
from redash import settings, app, db, models, data_manager, __version__
from redash.import_export import import_manager from redash.import_export import import_manager
from flask.ext.script import Manager, prompt_pass from flask.ext.script import Manager, prompt_pass
@@ -22,32 +19,18 @@ def version():
@manager.command @manager.command
def runworkers(): def runworkers():
"""Starts the re:dash query executors/workers.""" """Prints deprecation warning."""
print "** This command is deprecated. Please use Celery's CLI to control the workers. **"
def stop_handler(signum, frame): # TODO: Move to celery beat?
logging.warning("Exiting; waiting for workers") # while True:
data_manager.stop_workers() # try:
exit() # data_manager.refresh_queries()
# data_manager.report_status()
signal.signal(signal.SIGTERM, stop_handler) # except Exception as e:
signal.signal(signal.SIGINT, stop_handler) # logging.error("Something went wrong with refreshing queries...")
# logging.exception(e)
old_workers = data_manager.redis_connection.smembers('workers') # time.sleep(60)
data_manager.redis_connection.delete('workers')
logging.info("Cleaning old workers: %s", old_workers)
data_manager.start_workers(settings.WORKERS_COUNT)
logging.info("Workers started.")
while True:
try:
data_manager.refresh_queries()
data_manager.report_status()
except Exception as e:
logging.error("Something went wrong with refreshing queries...")
logging.exception(e)
time.sleep(60)
@manager.shell @manager.shell

View File

@@ -1,2 +1 @@
from manager import Manager from manager import Manager, Job
from worker import Job

View File

@@ -40,7 +40,7 @@ def parse_boolean(str):
NAME = os.environ.get('REDASH_NAME', 're:dash') NAME = os.environ.get('REDASH_NAME', 're:dash')
REDIS_URL = os.environ.get('REDASH_REDIS_URL', "redis://localhost:6379") REDIS_URL = os.environ.get('REDASH_REDIS_URL', "redis://localhost:6379/0")
STATSD_HOST = os.environ.get('REDASH_STATSD_HOST', "127.0.0.1") STATSD_HOST = os.environ.get('REDASH_STATSD_HOST', "127.0.0.1")
STATSD_PORT = int(os.environ.get('REDASH_STATSD_PORT', "8125")) STATSD_PORT = int(os.environ.get('REDASH_STATSD_PORT', "8125"))