mirror of
https://github.com/getredash/redash.git
synced 2025-12-20 01:47:39 -05:00
Add server starting option to manage.py.
This commit is contained in:
23
manage.py
23
manage.py
@@ -9,10 +9,10 @@ atfork.stdlib_fixer.fix_logging_module()
|
|||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
from redash import settings, data, redis_connection, data_manager
|
from redash import settings, app, data_manager
|
||||||
|
|
||||||
|
|
||||||
def start_workers(data_manager):
|
def start_workers():
|
||||||
try:
|
try:
|
||||||
old_workers = data_manager.redis_connection.smembers('workers')
|
old_workers = data_manager.redis_connection.smembers('workers')
|
||||||
data_manager.redis_connection.delete('workers')
|
data_manager.redis_connection.delete('workers')
|
||||||
@@ -34,17 +34,32 @@ def start_workers(data_manager):
|
|||||||
data_manager.stop_workers()
|
data_manager.stop_workers()
|
||||||
|
|
||||||
|
|
||||||
|
def start_server(port, debug):
|
||||||
|
app.run(debug=debug, port=port)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
channel = logging.StreamHandler()
|
channel = logging.StreamHandler()
|
||||||
logging.getLogger().addHandler(channel)
|
logging.getLogger().addHandler(channel)
|
||||||
logging.getLogger().setLevel(settings.LOG_LEVEL)
|
logging.getLogger().setLevel(settings.LOG_LEVEL)
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("command")
|
subparsers = parser.add_subparsers(title='command', dest='command')
|
||||||
|
|
||||||
|
subparsers.add_parser('worker', help='start query execution workers')
|
||||||
|
server_parser = subparsers.add_parser('server', help='start api server')
|
||||||
|
server_parser.add_arguemnt('--debug',
|
||||||
|
action='store_true',
|
||||||
|
help='start in debug mode (code reload)')
|
||||||
|
server_parser.add_arguemnt('--port',
|
||||||
|
default=8888,
|
||||||
|
help='port to bind to')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.command == "worker":
|
if args.command == "worker":
|
||||||
start_workers(data_manager)
|
start_workers()
|
||||||
|
elif args.command == 'server':
|
||||||
|
start_server(args.port, args.debug)
|
||||||
else:
|
else:
|
||||||
print "Unknown command"
|
print "Unknown command"
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,8 @@
|
|||||||
"""
|
"""
|
||||||
Flask-restful based API implementation for re:dash.
|
Flask-restful based API implementation for re:dash.
|
||||||
|
|
||||||
Also at the moment the Flask server is used to serve the static assets (and the Angular.js app),
|
Currently the Flask server is used to serve the static assets (and the Angular.js app),
|
||||||
but this is only due to configuration issues and temporary.
|
but this is only due to configuration issues and temporary.
|
||||||
|
|
||||||
Usage:
|
|
||||||
python api.py [--port=8888] [--debug] [--static=..]
|
|
||||||
|
|
||||||
port - port to listen to
|
|
||||||
debug - enable debug mode (extensive logging, restart on code change)
|
|
||||||
static - static assets path
|
|
||||||
|
|
||||||
If static option isn't specified it will be taken from settings.py.
|
|
||||||
"""
|
"""
|
||||||
import csv
|
import csv
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|||||||
Reference in New Issue
Block a user