Created
September 22, 2016 04:15
-
-
Save briandeheus/b479ccdbb9217e4239ad33f746a60675 to your computer and use it in GitHub Desktop.
Chronos Utilities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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