Skip to content

Commit

Permalink
CLI adding refresh_druid command
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Feb 12, 2016
1 parent d970e89 commit 1f41ce3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions panoramix/bin/panoramix
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python

from datetime import datetime
import logging
from subprocess import Popen

from flask.ext.script import Manager
Expand Down Expand Up @@ -62,6 +64,25 @@ def load_examples(sample):
print("Loading [Birth names]")
data.load_birth_names()

@manager.command
def refresh_druid():
"""Refresh all druid datasources"""
session = db.session()
from panoramix import models
for cluster in session.query(models.DruidCluster).all():
try:
cluster.refresh_datasources()
except Exception as e:
print(
"Error while processing cluster '{}'\n{}".format(
cluster, str(e)))
logging.exception(e)
cluster.metadata_last_refreshed = datetime.now()
print(
"Refreshed metadata from cluster "
"[" + cluster.cluster_name + "]")
session.commit()


if __name__ == "__main__":
manager.run()

0 comments on commit 1f41ce3

Please sign in to comment.