Esempio n. 1
0
    def __init__(self, config):
        super(GADRunnerThread, self).__init__()
        import sys
        import time

        from gitautodeploy import GitAutoDeploy

        self._app = GitAutoDeploy()
        self._app.setup(config)

        # Store PID and port in thread instance
        self.pid = self._app._pid
        self.port = self._app._port
Esempio n. 2
0
    def __init__(self, config):
        super(GADRunnerThread, self).__init__()
        import sys
        import time

        from gitautodeploy import GitAutoDeploy

        self._app = GitAutoDeploy()
        self._app.setup(config)

        # Setup HTTP server, but do not start serving
        self._app.serve_http(serve_forever=False)

        # Store PID and port in thread instance
        self.pid = self._app._pid
        self.port = self._app._http_port
Esempio n. 3
0
    def __init__(self, config):
        super(GADRunnerThread, self).__init__()
        import sys
        import time

        from gitautodeploy import GitAutoDeploy

        self._app = GitAutoDeploy()
        self._app.setup(config)

        # Store PID and port in thread instance
        self.pid = self._app._pid
        self.port = self._app._port
Esempio n. 4
0
class GADRunnerThread(threading.Thread):
    def __init__(self, config):
        super(GADRunnerThread, self).__init__()
        import sys
        import time

        from gitautodeploy import GitAutoDeploy

        self._app = GitAutoDeploy()
        self._app.setup(config)

        # Store PID and port in thread instance
        self.pid = self._app._pid
        self.port = self._app._port

    def run(self):
        self._app.handle_request()

    def exit(self):
        self._app.stop()
        self._app.close()
Esempio n. 5
0
class GADRunnerThread(threading.Thread):
    def __init__(self, config):
        super(GADRunnerThread, self).__init__()
        import sys
        import time

        from gitautodeploy import GitAutoDeploy

        self._app = GitAutoDeploy()
        self._app.setup(config)

        # Store PID and port in thread instance
        self.pid = self._app._pid
        self.port = self._app._port

    def run(self):
        self._app.handle_request()

    def exit(self):
        self._app.stop()
        self._app.close()
Esempio n. 6
0
class GADRunnerThread(threading.Thread):
    def __init__(self, config):
        super(GADRunnerThread, self).__init__()
        import sys
        import time

        from gitautodeploy import GitAutoDeploy

        self._app = GitAutoDeploy()
        self._app.setup(config)

        # Setup HTTP server, but do not start serving
        self._app.serve_http(serve_forever=False)

        # Store PID and port in thread instance
        self.pid = self._app._pid
        self.port = self._app._http_port

    def run(self):
        self._app._http_server.handle_request()

    def exit(self):
        self._app.stop()
        self._app.close()
Esempio n. 7
0
def main():
    import signal
    from gitautodeploy import GitAutoDeploy
    from cli.config import get_config_defaults, get_config_from_environment
    from cli.config import get_config_from_argv, find_config_file
    from cli.config import get_config_from_file, get_repo_config_from_environment
    from cli.config import init_config, get_config_file_path, rename_legacy_attribute_names
    from cli.config import ConfigFileNotFoundException, ConfigFileInvalidException
    import logging
    import sys
    import os

    logger = logging.getLogger()

    app = GitAutoDeploy()

    if hasattr(signal, 'SIGHUP'):
        signal.signal(signal.SIGHUP, app.signal_handler)
    if hasattr(signal, 'SIGINT'):
        signal.signal(signal.SIGINT, app.signal_handler)
    if hasattr(signal, 'SIGABRT'):
        signal.signal(signal.SIGABRT, app.signal_handler)
    if hasattr(signal, 'SIGPIPE') and hasattr(signal, 'SIG_IGN'):
        signal.signal(signal.SIGPIPE, signal.SIG_IGN)

    # Get default config values
    config = get_config_defaults()

    # Get config values from environment variables and commadn line arguments
    environment_config = get_config_from_environment()
    argv_config = get_config_from_argv(sys.argv[1:])

    # Merge config values from environment variables
    config.update(environment_config)

    search_target = os.path.dirname(os.path.realpath(__file__))
    config_file_path = get_config_file_path(environment_config, argv_config, search_target)

    # Config file path provided or found?
    if config_file_path:

        try:
            file_config = get_config_from_file(config_file_path)
        except ConfigFileNotFoundException as e:
            app.setup_console_logger()
            logger.critical("No config file not found at '%s'" % e)
            return
        except ConfigFileInvalidException as e:
            app.setup_console_logger()
            logger.critical("Unable to read config file due to invalid JSON format in '%s'" % e)
            return

        # Merge config values from config file (overrides environment variables)
        config.update(file_config)

    # Merge config value from command line (overrides environment variables and config file)
    config.update(argv_config)

    # Rename legacy config option names
    config = rename_legacy_attribute_names(config)

    # Extend config data with any repository defined by environment variables
    repo_config = get_repo_config_from_environment()

    if repo_config:

        if not 'repositories' in config:
            config['repositories'] = []

        config['repositories'].append(repo_config)

    # Initialize config by expanding with missing values
    init_config(config)

    app.setup(config)
    app.serve_forever()
Esempio n. 8
0
def main():
    import signal
    from gitautodeploy import GitAutoDeploy
    from cli.config import get_config_defaults, get_config_from_environment
    from cli.config import get_config_from_argv, find_config_file
    from cli.config import get_config_from_file, get_repo_config_from_environment
    from cli.config import init_config, get_config_file_path, rename_legacy_attribute_names
    from cli.config import ConfigFileNotFoundException, ConfigFileInvalidException
    import logging
    import sys
    import os

    logger = logging.getLogger()

    app = GitAutoDeploy()

    if hasattr(signal, 'SIGHUP'):
        signal.signal(signal.SIGHUP, app.signal_handler)
    if hasattr(signal, 'SIGINT'):
        signal.signal(signal.SIGINT, app.signal_handler)
    if hasattr(signal, 'SIGABRT'):
        signal.signal(signal.SIGABRT, app.signal_handler)
    if hasattr(signal, 'SIGPIPE') and hasattr(signal, 'SIG_IGN'):
        signal.signal(signal.SIGPIPE, signal.SIG_IGN)

    # Get default config values
    config = get_config_defaults()

    # Get config values from environment variables and commadn line arguments
    environment_config = get_config_from_environment()
    argv_config = get_config_from_argv(sys.argv[1:])

    # Merge config values from environment variables
    config.update(environment_config)

    search_target = os.path.dirname(os.path.realpath(__file__))
    config_file_path = get_config_file_path(environment_config, argv_config, search_target)

    # Config file path provided or found?
    if config_file_path:

        try:
            file_config = get_config_from_file(config_file_path)
        except ConfigFileNotFoundException as e:
            app.setup_console_logger()
            logger.critical("No config file not found at '%s'" % e)
            return
        except ConfigFileInvalidException as e:
            app.setup_console_logger()
            logger.critical("Unable to read config file due to invalid JSON format in '%s'" % e)
            return

        # Merge config values from config file (overrides environment variables)
        config.update(file_config)

    # Merge config value from command line (overrides environment variables and config file)
    config.update(argv_config)

    # Rename legacy config option names
    config = rename_legacy_attribute_names(config)

    # Extend config data with any repository defined by environment variables
    repo_config = get_repo_config_from_environment()

    if repo_config:

        if not 'repositories' in config:
            config['repositories'] = []

        config['repositories'].append(repo_config)

    # Initialize config by expanding with missing values
    init_config(config)

    app.setup(config)
    app.serve_forever()