Skip to content

Commit

Permalink
Increase verbosity of logging messages #2
Browse files Browse the repository at this point in the history
  • Loading branch information
miketonks committed Jul 13, 2015
1 parent bbd358e commit aefbca0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions governor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
from helpers.postgresql import Postgresql
from helpers.ha import Ha

LOG_LEVEL = logging.DEBUG if os.getenv('DEBUG', None) else logging.INFO

logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=logging.INFO)
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=LOG_LEVEL)

f = open(sys.argv[1], "r")
config = yaml.load(f.read())
Expand Down Expand Up @@ -40,13 +41,15 @@ def stop_postgresql():
logging.info("Governor Starting up: Empty Data Dir")
# racing to initialize
if etcd.race("/initialize", postgresql.name):
logging.info("Governor Starting up: Initialisation Race ... WON!!!")
logging.info("Governor Starting up: Initialise Postgres")
postgresql.initialize()
logging.info("Governor Starting up: Initialise Complete")
etcd.take_leader(postgresql.name)
logging.info("Governor Starting up: Starting Postgres")
postgresql.start()
else:
logging.info("Governor Starting up: Initialisation Race ... LOST")
logging.info("Governor Starting up: Sync Postgres from Leader")
synced_from_leader = False
while not synced_from_leader:
Expand All @@ -70,10 +73,11 @@ def stop_postgresql():

logging.info("Governor Running: Starting Running Loop")
while True:
logging.info(ha.run_cycle())
logging.info("Governor Running: %s" % ha.run_cycle())

# create replication slots
if postgresql.is_leader():
logging.info("Governor Running: I am the Leader")
for node in etcd.get_client_path("/members?recursive=true")["node"]["nodes"]:
member = node["key"].split('/')[-1]
if member != postgresql.name:
Expand Down
1 change: 1 addition & 0 deletions helpers/ha.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def run_cycle(self):
try:
if self.state_handler.is_healthy():
if self.is_unlocked():
logging.info("Leader is unlocked - starting election")
if self.state_handler.is_healthiest_node(self.etcd):
if self.acquire_lock():
if not self.state_handler.is_leader():
Expand Down

0 comments on commit aefbca0

Please sign in to comment.