Beispiel #1
0
def poller(args):
    """Process 'show poller' commands.

    Args:
        args: Argparse arguments

    Returns:
        None

    """
    if args.subqualifier == 'logs':
        # Process logs
        config = configuration.Config()
        filename = config.log_file()
        tail = input_output.File(filename)
        tail.tail()

        # Done
        sys.exit(0)

    elif args.subqualifier == 'status':
        # Create agent objects
        agent_poller = Agent(POLLER_EXECUTABLE)

        # Get agent status
        daemon_poller = AgentDaemon(agent_poller)
        daemon_poller.status()

        # Done
        sys.exit(0)

    # Show help if there are no matches
    general.cli_help()
Beispiel #2
0
def poller():
    """Process 'start poller' commands.

    Args:
        None

    Returns:
        None

    """
    # Check existence of systemd file
    if general.systemd_exists(POLLER_EXECUTABLE) is True:
        general.systemd_daemon(POLLER_EXECUTABLE, action='start')
    else:
        # Check user
        general.check_user()

        # Create agent object
        agent_poller = Agent(POLLER_EXECUTABLE)

        # Start agent
        daemon_poller = AgentDaemon(agent_poller)
        daemon_poller.start()

    # Done
    sys.exit(0)
Beispiel #3
0
def api():
    """Process 'start api' commands.

    Args:
        None

    Returns:
        None

    """
    # Check existence of systemd file
    if general.systemd_exists(API_EXECUTABLE) is True:
        general.systemd_daemon(API_EXECUTABLE, action='start')
    else:
        # Check user
        general.check_user()

        # Create agent objects
        agent_gunicorn = Agent(API_GUNICORN_AGENT)
        agent_api = AgentAPI(API_EXECUTABLE, API_GUNICORN_AGENT)

        # Start daemons (API first, Gunicorn second)
        daemon_api = AgentDaemon(agent_api)
        daemon_api.start()
        daemon_gunicorn = AgentDaemon(agent_gunicorn)
        daemon_gunicorn.start()

    # Done
    sys.exit(0)
Beispiel #4
0
def poller(args):
    """Process 'stop poller' commands.

    Args:
        args: Argparse arguments

    Returns:
        None

    """
    if general.systemd_exists(POLLER_EXECUTABLE) is True:
        general.systemd_daemon(POLLER_EXECUTABLE, action='stop')
    else:
        # Check user
        general.check_user()

        # Create agent object
        agent_poller = Agent(POLLER_EXECUTABLE)

        # Stop daemon
        daemon_poller = AgentDaemon(agent_poller)
        if args.force is True:
            daemon_poller.force()
        daemon_poller.stop()

    # Done
    sys.exit(0)
Beispiel #5
0
def poller(args):
    """Process 'restart poller' commands.

    Args:
        args: Argparse arguments

    Returns:
        None

    """
    # Check existence of systemd file
    if general.systemd_exists(POLLER_EXECUTABLE) is True:
        general.systemd_daemon(POLLER_EXECUTABLE, action='restart')
    else:
        # Check user
        general.check_user()

        # Create agent object
        agent_poller = Agent(POLLER_EXECUTABLE)

        # Restart daemon
        daemon_poller = AgentDaemon(agent_poller)
        if args.force is True:
            daemon_poller.force()
        daemon_poller.restart()

    # Done
    sys.exit(0)
Beispiel #6
0
def api(args):
    """Process 'show api' commands.

    Args:
        args: Argparse arguments

    Returns:
        None

    """
    if args.subqualifier == 'logs':
        # Process logs
        config = configuration.Config()
        filename = config.web_log_file()
        tail = input_output.File(filename)
        tail.tail()

        # Done
        sys.exit(0)

    elif args.subqualifier == 'status':
        # Create agent objects
        agent_gunicorn = Agent(API_GUNICORN_AGENT)
        agent_api = AgentAPI(API_EXECUTABLE, API_GUNICORN_AGENT)

        # Get agent status
        daemon_gunicorn = AgentDaemon(agent_gunicorn)
        daemon_gunicorn.status()
        daemon_api = AgentDaemon(agent_api)
        daemon_api.status()

        # Done
        sys.exit(0)

    # Show help if there are no matches
    general.cli_help()
Beispiel #7
0
def api(args):
    """Process 'stop api' commands.

    Args:
        args: Argparse arguments

    Returns:
        None

    """
    if general.systemd_exists(API_EXECUTABLE) is True:
        general.systemd_daemon(API_EXECUTABLE, action='stop')
    else:
        # Check user
        general.check_user()

        # Create agent objects
        agent_gunicorn = Agent(API_GUNICORN_AGENT)
        agent_api = AgentAPI(API_EXECUTABLE, API_GUNICORN_AGENT)

        # Stop daemons
        daemon_gunicorn = AgentDaemon(agent_gunicorn)
        daemon_api = AgentDaemon(agent_api)
        if args.force is True:
            daemon_gunicorn.force()
            daemon_api.force()
        daemon_gunicorn.stop()
        daemon_api.stop()

    # Done
    sys.exit(0)