Beispiel #1
0
def test_get_worker_count(kind_name, env_vars, cpu_affinity, multiplier,
                          minimum, maximum, expected):
    class FakeProcess(object):
        def __init__(self, pid):
            pass

        def cpu_affinity(self):
            return cpu_affinity

    with patch("os.environ.get", env_vars.get):
        with patch("psutil.Process", FakeProcess):
            assert get_worker_count(kind_name, multiplier, minimum,
                                    maximum) == expected
Beispiel #2
0
import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), "../"))

import logging

from Crypto import Random
from util.log import logfile_path
from util.workers import get_worker_count, get_worker_connections_count

logconfig = logfile_path(debug=False)

bind = "unix:/tmp/gunicorn_verbs.sock"
workers = get_worker_count("verbs", 2, minimum=2, maximum=32)
worker_connections = get_worker_connections_count("verbs")
pythonpath = "."
preload_app = True
timeout = 2000  # Because sync workers


def post_fork(server, worker):
    # Reset the Random library to ensure it won't raise the "PID check failed." error after
    # gunicorn forks.
    Random.atfork()


def when_ready(server):
    logger = logging.getLogger(__name__)
    logger.debug(
        "Starting verbs gunicorn with %s workers and sync worker class",
Beispiel #3
0
import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), "../"))

import logging

from Crypto import Random
from util.log import logfile_path
from util.workers import get_worker_count, get_worker_connections_count

logconfig = logfile_path(debug=False)
bind = "unix:/tmp/gunicorn_registry.sock"
workers = get_worker_count("registry", 4, minimum=8, maximum=64)
worker_class = "gevent"
worker_connections = get_worker_connections_count("registry")
pythonpath = "."
preload_app = True


def post_fork(server, worker):
    # Reset the Random library to ensure it won't raise the "PID check failed." error after
    # gunicorn forks.
    Random.atfork()


def when_ready(server):
    logger = logging.getLogger(__name__)
    logger.debug(
        "Starting registry gunicorn with %s workers and %s worker class",
        workers, worker_class)
Beispiel #4
0
monkey.patch_all()

import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), "../"))

import logging

from util.log import logfile_path
from util.workers import get_worker_count, get_worker_connections_count

logconfig = logfile_path(debug=False)

bind = "unix:/tmp/gunicorn_web.sock"
workers = get_worker_count("web", 2, minimum=2, maximum=32)
worker_class = "gevent"
worker_connections = get_worker_connections_count("web")
pythonpath = "."
if os.getenv("QUAY_HOTRELOAD", "false") == "true":
    reload = True
    reload_engine = "auto"
else:
    preload_app = True


def when_ready(server):
    logger = logging.getLogger(__name__)
    logger.debug("Starting web gunicorn with %s workers and %s worker class",
                 workers, worker_class)
Beispiel #5
0
import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), "../"))

import logging

from Crypto import Random
from util.log import logfile_path
from util.workers import get_worker_count, get_worker_connections_count

logconfig = logfile_path(debug=False)
bind = "unix:/tmp/gunicorn_secscan.sock"
workers = get_worker_count("secscan", 2, minimum=2, maximum=4)
worker_class = "gevent"
worker_connections = get_worker_connections_count("secscan")
pythonpath = "."
preload_app = True


def post_fork(server, worker):
    # Reset the Random library to ensure it won't raise the "PID check failed." error after
    # gunicorn forks.
    Random.atfork()


def when_ready(server):
    logger = logging.getLogger(__name__)
    logger.debug(
        "Starting secscan gunicorn with %s workers and %s worker class",
        workers, worker_class)
Beispiel #6
0
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), "../"))

import logging

from Crypto import Random
from util.log import logfile_path
from util.workers import get_worker_count

logconfig = logfile_path(debug=False)

bind = 'unix:/tmp/gunicorn_verbs.sock'
workers = get_worker_count('verbs', 2, minimum=2, maximum=32)
pythonpath = '.'
preload_app = True
timeout = 2000  # Because sync workers


def post_fork(server, worker):
    # Reset the Random library to ensure it won't raise the "PID check failed." error after
    # gunicorn forks.
    Random.atfork()


def when_ready(server):
    logger = logging.getLogger(__name__)
    logger.debug(
        'Starting verbs gunicorn with %s workers and sync worker class',
        workers)
Beispiel #7
0
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), "../"))

import logging

from Crypto import Random
from util.log import logfile_path
from util.workers import get_worker_count

logconfig = logfile_path(debug=True)
bind = '0.0.0.0:5000'
workers = get_worker_count('local', 2, minimum=2, maximum=8)
worker_class = 'gevent'
daemon = False
pythonpath = '.'
preload_app = True


def post_fork(server, worker):
    # Reset the Random library to ensure it won't raise the "PID check failed." error after
    # gunicorn forks.
    Random.atfork()


def when_ready(server):
    logger = logging.getLogger(__name__)
    logger.debug('Starting local gunicorn with %s workers and %s worker class',
                 workers, worker_class)
Beispiel #8
0
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), "../"))

import logging

from Crypto import Random
from util.log import logfile_path
from util.workers import get_worker_count

logconfig = logfile_path(debug=False)

bind = 'unix:/tmp/gunicorn_web.sock'
workers = get_worker_count('web', 2, minimum=2, maximum=32)
worker_class = 'gevent'
pythonpath = '.'
preload_app = True


def post_fork(server, worker):
    # Reset the Random library to ensure it won't raise the "PID check failed." error after
    # gunicorn forks.
    Random.atfork()


def when_ready(server):
    logger = logging.getLogger(__name__)
    logger.debug('Starting web gunicorn with %s workers and %s worker class',
                 workers, worker_class)
Beispiel #9
0
import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), "../"))

import logging

from util.log import logfile_path
from util.workers import get_worker_count, get_worker_connections_count

logconfig = logfile_path(debug=True)
bind = "0.0.0.0:5000"
workers = get_worker_count("local", 2, minimum=2, maximum=8)
worker_class = "gevent"
worker_connections = get_worker_connections_count("local")
daemon = False
pythonpath = "."
if os.getenv("QUAY_HOTRELOAD", "false") == "true":
    reload = True
    reload_engine = "auto"
else:
    preload_app = True


def when_ready(server):
    logger = logging.getLogger(__name__)
    logger.debug("Starting local gunicorn with %s workers and %s worker class",
                 workers, worker_class)
Beispiel #10
0
import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), "../"))

import logging

from Crypto import Random
from util.log import logfile_path
from util.workers import get_worker_count

logconfig = logfile_path(debug=False)
bind = 'unix:/tmp/gunicorn_registry.sock'
workers = get_worker_count('registry', 4, minimum=8, maximum=64)
worker_class = 'gevent'
pythonpath = '.'
preload_app = True


def post_fork(server, worker):
    # Reset the Random library to ensure it won't raise the "PID check failed." error after
    # gunicorn forks.
    Random.atfork()


def when_ready(server):
    logger = logging.getLogger(__name__)
    logger.debug(
        'Starting registry gunicorn with %s workers and %s worker class',
        workers, worker_class)
Beispiel #11
0
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), "../"))

import logging

from Crypto import Random
from util.log import logfile_path
from util.workers import get_worker_count


logconfig = logfile_path(debug=False)
bind = 'unix:/tmp/gunicorn_secscan.sock'
workers = get_worker_count('secscan', 2, minimum=2, maximum=4)
worker_class = 'gevent'
pythonpath = '.'
preload_app = True


def post_fork(server, worker):
  # Reset the Random library to ensure it won't raise the "PID check failed." error after
  # gunicorn forks.
  Random.atfork()

def when_ready(server):
  logger = logging.getLogger(__name__)
  logger.debug('Starting secscan gunicorn with %s workers and %s worker class', workers,
               worker_class)