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 10, 2015
1 parent bf3e98f commit d5d251b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 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)

# load passed config file, or default
config_file = 'postgres0.yml'
Expand All @@ -25,6 +26,9 @@
if os.getenv('GOVERNOR_POSTGRESQL_NAME'):
config['postgresql']['name'] = os.getenv('GOVERNOR_POSTGRESQL_NAME')

if os.getenv('GOVERNOR_POSTGRESQL_CONNECT'):
config['postgresql']['connect'] = os.getenv('GOVERNOR_POSTGRESQL_CONNECT')

if os.getenv('GOVERNOR_POSTGRESQL_LISTEN'):
config['postgresql']['listen'] = os.getenv('GOVERNOR_POSTGRESQL_LISTEN')

Expand Down Expand Up @@ -60,13 +64,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 @@ -90,10 +96,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 member in etcd.members():
member = member['hostname']
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 d5d251b

Please sign in to comment.