Skip to content

Instantly share code, notes, and snippets.

@briandeheus
Created September 22, 2016 04:15
Show Gist options
  • Save briandeheus/b479ccdbb9217e4239ad33f746a60675 to your computer and use it in GitHub Desktop.
Save briandeheus/b479ccdbb9217e4239ad33f746a60675 to your computer and use it in GitHub Desktop.
Chronos Utilities
from datetime import datetime
import sys
import os
def handle_sigterm(*args, **kwargs):
"""
Handle termination of the application via SIGTERM.
:param args:
:param kwargs:
:return:
"""
write_to_file('Stopping Chronos because of SIGINT')
sys.exit(0)
def write_to_file(message):
"""
Write a message to file
:param message:
:return:
"""
with open('/var/log/chronos-{}.log'.format(os.getenv('CHRONOS_LOG_SUFFIX', 'unknown')), 'a') as f:
f.write('{}\n'.format(message))
def write_time_to_file():
"""
Write the current time to log.
:return:
"""
now = datetime.utcnow()
write_to_file(now)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment