Пример #1
0
def values_command(sock, args, instance):
    """Return all values stored in Papa"""
    instance_globals = instance['globals']
    with instance_globals['lock']:
        return '\n'.join(
            sorted('{0} {1}'.format(key, value) for key, value in
                   wildcard_iter(instance_globals['values'], args)))
Пример #2
0
def watch_command(sock, args, instance):
    """Watch a process"""
    instance_globals = instance['globals']
    all_processes = instance_globals['processes']
    with instance_globals['lock']:
        procs = dict((name, {'p': proc, 't': 0, 'closed': False}) for name, proc in wildcard_iter(all_processes, args, True))
    if not procs:
        raise utils.Error('Nothing to watch')
    send_with_retry(sock, cast_bytes('Watching {0}\n'.format(len(procs))))
    return _do_watch(sock, procs, instance)
Пример #3
0
def processes_command(sock, args, instance):
    """List active processes.

You can list processes by name or PID
Examples:
    list process 3698
    list processes nginx.*
"""
    instance_globals = instance['globals']
    with instance_globals['lock']:
        return '\n'.join(sorted('{0}'.format(proc) for _, proc in wildcard_iter(instance_globals['processes'], args)))
Пример #4
0
def sockets_command(sock, args, instance):
    """List active sockets.

You can list sockets by name or file number
Examples:
    list socket 10
    list socket uwsgi.*
"""
    instance_globals = instance['globals']
    with instance_globals['lock']:
        return '\n'.join(sorted('{0}'.format(s) for _, s in wildcard_iter(instance_globals['sockets']['by_name'], args)))
Пример #5
0
def close_socket_command(sock, args, instance):
    """Close and remove socket or sockets

You can remove sockets by name or file number
Examples:
    remove sockets uwsgi
    remove socket 10
"""
    instance_globals = instance['globals']
    with instance_globals['lock']:
        for name, p in wildcard_iter(instance_globals['sockets']['by_name'], args, required=True):
            p.close()
Пример #6
0
def sockets_command(sock, args, instance):
    """List active sockets.

You can list sockets by name or file number
Examples:
    list socket 10
    list socket uwsgi.*
"""
    instance_globals = instance['globals']
    with instance_globals['lock']:
        return '\n'.join(
            sorted('{0}'.format(s) for _, s in wildcard_iter(
                instance_globals['sockets']['by_name'], args)))
Пример #7
0
def processes_command(sock, args, instance):
    """List active processes.

You can list processes by name or PID
Examples:
    list process 3698
    list processes nginx.*
"""
    instance_globals = instance['globals']
    with instance_globals['lock']:
        return '\n'.join(
            sorted('{0}'.format(proc) for _, proc in wildcard_iter(
                instance_globals['processes'], args)))
Пример #8
0
def close_output_command(sock, args, instance):
    """Close the process output channels and automatically remove the process from
the list on completion.

You can remove processes by name or PID
Examples:
    remove processes uwsgi
    remove process 10
"""
    """Close the process output channels and automatically remove the process when done"""
    instance_globals = instance['globals']
    with instance_globals['lock']:
        for name, p in wildcard_iter(instance_globals['processes'], args, required=True):
            p.close_output()
Пример #9
0
def remove_command(sock, args, instance):
    """Remove a named value or set of values. You cannot 'remove *'.

Examples:
    remove count
    remove circus.*
"""
    if not args or args == ['*']:
        raise Error('You cannot remove all variables')
    instance_globals = instance['globals']
    values = instance_globals['values']
    with instance_globals['lock']:
        for name, _ in wildcard_iter(values, args):
            del values[name]
Пример #10
0
def close_socket_command(sock, args, instance):
    """Close and remove socket or sockets

You can remove sockets by name or file number
Examples:
    remove sockets uwsgi
    remove socket 10
"""
    instance_globals = instance['globals']
    with instance_globals['lock']:
        for name, p in wildcard_iter(instance_globals['sockets']['by_name'],
                                     args,
                                     required=True):
            p.close()
Пример #11
0
def remove_command(sock, args, instance):
    """Remove a named value or set of values. You cannot 'remove *'.

Examples:
    remove count
    remove circus.*
"""
    if not args or args == ['*']:
        raise Error('You cannot remove all variables')
    instance_globals = instance['globals']
    values = instance_globals['values']
    with instance_globals['lock']:
        for name, _ in wildcard_iter(values, args):
            del values[name]
Пример #12
0
def watch_command(sock, args, instance):
    """Watch a process"""
    instance_globals = instance['globals']
    all_processes = instance_globals['processes']
    with instance_globals['lock']:
        procs = dict((name, {
            'p': proc,
            't': 0,
            'closed': False
        }) for name, proc in wildcard_iter(all_processes, args, True))
    if not procs:
        raise utils.Error('Nothing to watch')
    send_with_retry(sock, cast_bytes('Watching {0}\n'.format(len(procs))))
    return _do_watch(sock, procs, instance)
Пример #13
0
def close_output_command(sock, args, instance):
    """Close the process output channels and automatically remove the process from
the list on completion.

You can remove processes by name or PID
Examples:
    remove processes uwsgi
    remove process 10
"""
    """Close the process output channels and automatically remove the process when done"""
    instance_globals = instance['globals']
    with instance_globals['lock']:
        for name, p in wildcard_iter(instance_globals['processes'],
                                     args,
                                     required=True):
            p.close_output()
Пример #14
0
def values_command(sock, args, instance):
    """Return all values stored in Papa"""
    instance_globals = instance['globals']
    with instance_globals['lock']:
        return '\n'.join(sorted('{0} {1}'.format(key, value) for key, value in wildcard_iter(instance_globals['values'], args)))