|
|
@ -53,6 +53,11 @@ class Entrypoint(object):
|
|
|
|
"""Is command handled by entrypoint"""
|
|
|
|
"""Is command handled by entrypoint"""
|
|
|
|
return self.config.command.is_handled
|
|
|
|
return self.config.command.is_handled
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def is_disabled(self):
|
|
|
|
|
|
|
|
"""Return if service is disabled using environment"""
|
|
|
|
|
|
|
|
return 'ENTRYPOINT_DISABLE_SERVICE' in os.environ
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@property
|
|
|
|
def should_config(self):
|
|
|
|
def should_config(self):
|
|
|
|
"""Check environment to tell if config should apply anyway"""
|
|
|
|
"""Check environment to tell if config should apply anyway"""
|
|
|
@ -63,6 +68,15 @@ class Entrypoint(object):
|
|
|
|
"""Check if command output should be displayed using logging or not"""
|
|
|
|
"""Check if command output should be displayed using logging or not"""
|
|
|
|
return 'ENTRYPOINT_RAW' in os.environ
|
|
|
|
return 'ENTRYPOINT_RAW' in os.environ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def exit_if_disabled(self):
|
|
|
|
|
|
|
|
"""Exist 0 if service is disabled"""
|
|
|
|
|
|
|
|
if not self.is_disabled:
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.log.warning("Service is disabled by 'ENTRYPOINT_DISABLE_SERVICE' "
|
|
|
|
|
|
|
|
"environement variable... exiting with 0")
|
|
|
|
|
|
|
|
exit(0)
|
|
|
|
|
|
|
|
|
|
|
|
def apply_conf(self):
|
|
|
|
def apply_conf(self):
|
|
|
|
"""Apply config to template files"""
|
|
|
|
"""Apply config to template files"""
|
|
|
|
env = Environment(loader=FileSystemLoader('/'))
|
|
|
|
env = Environment(loader=FileSystemLoader('/'))
|
|
|
@ -120,6 +134,7 @@ def main(argv):
|
|
|
|
argv.pop(0)
|
|
|
|
argv.pop(0)
|
|
|
|
entry = Entrypoint(args=argv)
|
|
|
|
entry = Entrypoint(args=argv)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
entry.exit_if_disabled()
|
|
|
|
if not entry.is_handled and not entry.should_config:
|
|
|
|
if not entry.is_handled and not entry.should_config:
|
|
|
|
entry.log.warning("Running command without config")
|
|
|
|
entry.log.warning("Running command without config")
|
|
|
|
entry.launch()
|
|
|
|
entry.launch()
|
|
|
|