Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding interface option for admin CLI #6

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:2-slim

ENV PYTHONUNBUFFERED 1

RUN apt-get update && apt-get install -y git

RUN git clone https://github.com/mrname/tasktiger-admin.git

WORKDIR tasktiger-admin

RUN python setup.py install

EXPOSE 5000

CMD ["tasktiger-admin", "-i", "0.0.0.0"]
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
],
install_requires=[
'click',
'dsnparse',
'flask-admin',
'redis',
'redis>=2,<3',
'structlog',
'tasktiger>=0.4',
],
Expand Down
23 changes: 20 additions & 3 deletions tasktiger_admin/utils.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
import os

import click
import dsnparse
from flask import Flask
from flask_admin import Admin
import redis
from tasktiger import TaskTiger
from tasktiger_admin import TaskTigerView


@click.command()
@click.option('-h', '--host', help='Redis server hostname')
@click.option('-p', '--port', help='Redis server port')
@click.option('-a', '--password', help='Redis password')
@click.option('-n', '--db', help='Redis database number')
@click.option('-l', '--listen', help='Admin port to listen on')
def run_admin(host, port, db, password, listen):
@click.option('-i', '--interface', help='Admin interface to listen on',
default='127.0.0.1')
@click.option(
'--structlog/--no-structlog', default=True, help='Enable/Disable structlog'
)
def run_admin(host, port, db, password, listen, interface, **kwargs):
environ_dsn = os.environ.get('REDIS_URL', None)
if environ_dsn:
dsn_parsed = dsnparse.parse(environ_dsn)
host = host or dsn_parsed.host
port = port or dsn_parsed.port
password = dsn_parsed.password
conn = redis.Redis(host, int(port or 6379), int(db or 0), password)
tiger = TaskTiger(setup_structlog=True, connection=conn)
# FIXME - fix --no-structlog flag
# tiger = TaskTiger(setup_structlog=kwargs['structlog'], connection=conn)
tiger = TaskTiger(setup_structlog=False, connection=conn)
app = Flask(__name__)
admin = Admin(app, url='/')
admin.add_view(TaskTigerView(tiger, name='TaskTiger', endpoint='tasktiger'))
app.run(debug=True, port=int(listen or 5000))
app.run(debug=False, port=int(listen or 5000), host=interface)